C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; i m developing for pc now Code: #include <cstdlib> #include <iostream> #include <conio.h> using namespace std; int mult (int x, ...
-
09-17-2006, 07:47 AM #901Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
i m developing for pc now
the problem isCode:#include <cstdlib> #include <iostream> #include <conio.h> using namespace std; int mult (int x, int y); //samenbrengen inline void vermenigvuldigen() { int x; int y; cout<<"schrijf een getal voor te vermenigvuldigen/optellen/aftrekken of delen: "; cin>>x; cout<<"schrijf een tweede getal om het eerste mee te bewerken "; cin>>y; cin.ignore(); cout<<"het produkt van de 2 getallen is "<<mult (x,y)<<"\n"; cout<<"de som van de 2 getallen is "<<x+y<<"\n"; cout<<"het quotient van de 2 getallen is "<<x/y<<"\n"; cout<<"en met aftrekken bekomen we "<<x-y<<"\n"; printf("gemaakt door ROEL\n\n\n\n\n\n\n\n\n"); vermenigvuldigen(); cin.get(); } int mult (int x, int y) { return x*y; } int main() { vermenigvuldigen(); cin.get(); }
if you type 999999999999 , the program crashed
what can you do so you cant type it
ps : i tried this already
if (x>99999999){
printf("pleas enter another nuber, it's to big")
vermenigvuldigen();
}
-
09-17-2006, 07:55 AM #902AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
The int datatype can't handle that much data, change it to a long or something.
-
09-17-2006, 08:02 AM #903Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I thought both a long and int had the same size (4 bytes) on the psp? or have I been misinformed?
Zitat von homer
I use double for those huge variables.
-
09-17-2006, 08:03 AM #904Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
cant you block for using to much data???
so i can just use int???
-= Double Post =-
this is for PC
Zitat von waterbottle
(everbody told me to learn it first on pc and than on psp)Geändert von hallo007 (09-17-2006 um 08:03 AM Uhr) Grund: Automerged Doublepost
-
09-17-2006, 08:08 AM #905Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
ah, ok then.
Zitat von hallo007
I'm not sure, but maybe you could do:
if((cin>>y)>sizeof(int)) {
//code if to big
} else {
}
that might not work though..
-
09-17-2006, 08:09 AM #906AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
No it won't... He wouldn't be able to use the data.
You might want to change it to an unsigned int though.
Or if you want a long long (it can handle values from –9,223,372,036,854,775,80 7 to 9,223,372,036,854,775,807 )
-
09-17-2006, 08:58 AM #907Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
mayby i can just write an warning
that's easier for me:d
-
09-17-2006, 09:14 AM #908Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Could someone tell me if PC SDL and PSP SDL are the same?
thanks.
--Vaza
-
09-17-2006, 09:38 AM #909Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Not exactly no.
PSP SDL is slow as some of the rendering is done in software.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-17-2006, 10:11 AM #910sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
I think he means the functions though... As far as I know the functions should be he same
-
09-17-2006, 10:57 AM #911likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
@$$h4wl3$!
can someone explain to me the basic func's in C?
-
09-17-2006, 11:04 AM #912
printf("hello world")
prints hello world on the psp screen.
-
09-17-2006, 11:07 AM #913sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
um, no it doesnt...
Zitat von PSP-Maniac
it does if you define it like thisand still you didn't clarify the x and y coordinates..Code:#define printf pspDebugScreenPrintf
And if you want a full documentation check out this http://psp.jim.sh/pspsdk-doc/
-
09-17-2006, 11:08 AM #914
hehe sorry forgot that.
Zitat von Bronx
-
09-18-2006, 01:24 PM #915likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
coding
how can you change the text color in C?
-
09-18-2006, 01:34 PM #916AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Depends on what you use to print the text...
Zitat von psphacker12.
-
09-18-2006, 01:37 PM #917likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
i use
Code:pspDebugScreenPrintf("wassup homedawg, hows it hangin?")
-
09-18-2006, 01:43 PM #918AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Okay, then you'll have to use the
pspDebugScreenSetTextColo r
function.
Example:
Code:#define RGB(r,g,b) (((b)<<16)|((g)<<8)|(r)) int main(int argc, char **argv) { pspDebugScreenInit(); pspDebugScreenSetTextColor(RGB(255, 0, 0)); // change color to red pspDebugScreenPrintf("Red"); pspDebugScreenSetTextColor(RGB(0, 255, 0)); // change color to green pspDebugScreenPrintf("Green"); pspDebugScreenSetTextColor(RGB(0, 0, 255)); // change color to blue pspDebugScreenPrintf("Blue"); }
-
09-18-2006, 02:04 PM #919Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
If I wanted to change/read a memory address could I do somthing like this
int *pointer = 0x88000000;
?
and how could I do it if the memory address is a pointer to a different address and I wanted the pointer to point to that?
like,
int *pointer = 0x88000000;
0x88000000 is 0x88100004
so the pointer now points to 0x88100004. How should I do that?
-
09-18-2006, 04:51 PM #920QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
better typecast the address to a pointer (though it should compile with a mere warning without it):
int* pointer = (int*)0x88000000;
To change the pointer, just do
pointer = (int*)0x88100004;Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
09-18-2006, 09:44 PM #921Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Hi Guys,
After a little help with file IO .. writing/reading a file from two different buffers.
Yes I could copy them to a single buffer, and do it the normal way if there
were enough RAM, but there isn't.
I thought the above would work, but it doesn't seem to.. any ideas?Code:int f; f = sceIoOpen("./folder/file.txt", PSP_O_RDONLY, 0777); sceIoRead(f,buffer_a,10000); sceIoRead(f,buffer_b,20000); sceIoClose(f);
-= Double Post =-
forget it, that IS the right way,
I dunno what I was doing wrong before.Geändert von Art (09-18-2006 um 09:44 PM Uhr) Grund: Automerged Doublepost
-
09-19-2006, 03:52 PM #922QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- ~Behind You~
- Beiträge
- 884
- Points
- 8.011
- Level
- 60
- Downloads
- 0
- Uploads
- 0
ok can anyone show me how an hello world is made?
-
09-19-2006, 03:53 PM #923AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
-
09-19-2006, 04:01 PM #924QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- ~Behind You~
- Beiträge
- 884
- Points
- 8.011
- Level
- 60
- Downloads
- 0
- Uploads
- 0
wow thats hard to understand!
-= Double Post =-
i mean an hello world for the tiff sdkGeändert von Jetlitheone (09-19-2006 um 04:01 PM Uhr) Grund: Automerged Doublepost
-
09-19-2006, 04:03 PM #925Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
If you think hello world for the normal sdk is hard then I wouldn't advice you to try it with the tiffsdk
Zitat von Jetlitheone
-
09-19-2006, 04:05 PM #926QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- ~Behind You~
- Beiträge
- 884
- Points
- 8.011
- Level
- 60
- Downloads
- 0
- Uploads
- 0
its harder?
WOAH
-
09-19-2006, 04:18 PM #927sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
try learning the c language first by going here cprogramming.com
-
09-20-2006, 01:19 PM #928Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
1. hi guys. i need a couple of functions in C. i can seem to find anything.. (literally)
here is what i need: (i think they should all be in one of the libs)
a function that does the sin of something.
a function that does the cosin of something.
a function that does the tangent (tan) of something.
a function that converts degrees to radians
2. ALSO, how would i "blit" a 3D model to the screen using x,y,z positionst? (in 3D)
YES, i have read BILLIONS of tutorials, looked at the samples, BUT, all of them use prespective. i want to actually "blit" a model using x,y, and z coordinates, and be able to change them.--------------------------------------------------------------------------------------
-
09-20-2006, 01:36 PM #929AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
C already has built-in functions for sin, cos and tan. You just have to include math.h. The functions are named:
Zitat von Grimfate126
Code:sin(); cos(); tan();
-
09-20-2006, 01:44 PM #930Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von homer
wat about converting degrees to radians?--------------------------------------------------------------------------------------


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum