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; or you can use about.com or just google the command and it comes up with plenty of stuff...
-
03-31-2007, 11:41 AM #3601QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
or you can use about.com or just google the command and it comes up with plenty of stuff
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-31-2007, 11:58 AM #3602It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Sometimes pertaining to different languages...
I just use cppreference.com (C89/C++), cplusplus.com (C89/C++; more in-depth) or opengroup.org (C99) for my reference.
-
03-31-2007, 12:04 PM #3603QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Zitat von superbatxs
-_-Code:#include <stdio.h> int main() { FILE* pFile; // :| pFile = fopen("test.txt","r+b");// Open the file in reading and writing modes :| fseek(pFile,5,SEEK_SET); // Goes to 5 bytes after the beginning of the file. fprintf(pFile,"0"); // Writes 0 to the 6th byte... fclose(pFile); // :| return 0; // :| } /* Before: 123456789 After: 123450789 */[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
03-31-2007, 12:07 PM #3604QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
what is "r+b"? i only know of "r+"
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-31-2007, 12:09 PM #3605QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Open it in binary mode instead of text mode. If you dont specify b, it will likely open a file in text mode.
Zitat von slicer4ever
[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
03-31-2007, 12:13 PM #3606I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I think you're just supposed to use "rb", not "r+b". But they probably do the same thing.
Zitat von Moca

-
03-31-2007, 12:15 PM #3607It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
No, they don't. r+b is read/write binary mode. You can't use write functions with rb as your mode.
-
03-31-2007, 12:22 PM #3608QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
As the Archaemic said...
Zitat von Access_Denied
r and r+ are different.
r means read only
r+ means read and write
b means binary mode
rb means read in binary mode
r+b means read and write in binary mode[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
03-31-2007, 12:24 PM #3609QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
r+b was the only one i hadn't seen and i didn't put one and 2 together
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-31-2007, 12:27 PM #3610QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Oh, i didn't know you could do read and write and binary mode all together....thanks Moca, now it makes sense.
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-31-2007, 12:48 PM #3611QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
edit: nvm
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-31-2007, 02:28 PM #3612QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Hey guys, thanks for helping me learn file i/o writing x to y bytes. Thanks to you guys, my project is going great. Btw, i made a guide for people who would have trouble with this:
Post some C samplesCalypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-31-2007, 02:35 PM #3613QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Dammnit i wish i had developer status :|
Zitat von superbatxs
[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
03-31-2007, 02:38 PM #3614QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
IC, so what I would do is
Zitat von Moca
Correct?Code:if (fseek(gameEntry[current_selection].name,-4,SEEK_END) == ".mp3") { MP3_Init(); MP3_Load(gameEntry[current_selection].path); MP3_Play(); } }NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
03-31-2007, 02:51 PM #3615QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Remember one thing: developer status is what you need to strive for. I personally don't know you, but my advice to you is that releasing a good app doesn't always earn you dev status- you have to be smart in a lot of coding fields. I personally think you should be a dev, but just some advice for you. ;)
Zitat von Moca
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-31-2007, 03:18 PM #3616I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
There's one problem with your example Superbatxs. What if you don't know exactly where the 5 is? Here's an example that will replace the first 5 in the file with a 0. And it doesn't matter where it is in the file.
EDIT: Turns out that particular code doesn't work, but you get the idea.Code:#include <stdio.h> int main() { FILE* foo = fopen("foo.txt","r+b"); for(;;) { int get = fgetc(foo); if(get == 53) { fprintf(foo,"0"); break; } if(get == EOF) { printf("There is no 5 in the file."); sceKernelDelayThread(5*1000*1000); sceKernelExitGame(); } } fclose(foo); sceKernelExitGame(); }
-
03-31-2007, 03:29 PM #3617QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
No, not really. Dev status is more a random title than anything strived for, or measuring your smartness in "a lot of coding fields". Actually, it doesn't mean anything on these forums, but that the person has released any two or three end-user titles, be it a LUA pixel unstucking script or a full-blown Shell in C. It's as giving the title scientist to anyone that ever wrote an essay in school, while at the same time real scientists that do mainly background work don't get the title, for the plain reason that some newspaper columnists didn't recognize that work.Remember one thing: developer status is what you need to strive for. I personally don't know you, but my advice to you is that releasing a good app doesn't always earn you dev status- you have to be smart in a lot of coding fields. I personally think you should be a dev, but just some advice for you.
BTW: Quoting yourself in your sig is the same as masturbating to your own picture.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.
-
03-31-2007, 03:39 PM #3618QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
If it wasn't 2:39AM in here, I would've bursted to a very loud laugh
Zitat von Raphael
wheeee =:D
-
03-31-2007, 04:58 PM #3619QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Incorrect. You dont compare strings with ==.
Zitat von BlackShark
You use strcmp(string1,string2);
Code:if(strcmp(string1,string2) == 0) { printf("The strings %s and %s are equal \n",string1,string2); }[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
03-31-2007, 04:59 PM #3620I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Honestly, there are only about 15 people on this entire forum that should have dev status. Me, not being one of them.
Zitat von superbatxs

-
03-31-2007, 07:22 PM #3621QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
The purpose of my tutorial wasn't really to find a five and replace it with something. It was to write X to Y bytes in a file. Yea, you may be thinking that it's the same thing.....but let me put it in a different way (sorry i am bad at wording). It was also to find any number without knowing it, yet if you know its position in the file, then you replace it....um......well i don't know how else to put it. I had to use it for my G-Pack config file though, let's just say that.
Zitat von Access_Denied
I definitely agree with your first paragraph. However, i must say that saying that "Quoting yourself in your sig is the same as masturbating to your own picture" is just RUDE. I don't even know you, and why the hell are you being so mean??? Just keep your comments to yourself.......and btw, i can say some pretty mean things about you by just looking at your posts and your personality. I can keep that quote if i want, and i need to express myself by quoting myself, and showing kindness and love to other developers, then masturbation isn't exactly the situation
Zitat von Raphael
I definitely agree....with most of it. I agree that there are many people without dev status, however, i think you deserve it too. ;)
Zitat von Access_Denied
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-31-2007, 07:31 PM #3622Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
this isnt really psp related but its C++. is anyone familiar with allegro? if so then can you plz help me out here.
if not then i will just go to the allegro board but im making a game. and all goes well compiled and everything then upon running the game i get that stupid error report from windows asking if i want to send an error report. the last time i got this with a game i was making was when one of the pics was wrongly named and thus couldnt be loaded. if anyone knows what my problem is that would be nice but if not then thats ok becaues i realize this isnt really psp related.
Spoiler for Spoiler for code:
its not even that far into developement. and i still get this error.If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
04-01-2007, 02:22 AM #3623QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Sorry, I wasn't trying to be rude or sth. but that's just my opinion. Quoting yourself is an act of egomania (independent of the context), hence the (meant to be more funny than offensive) analogy to masturbation.
Zitat von superbatxs
Anyway, you're free to express your own opinion about me if you feel fit for it.
And yes, you're also totally free to keep that quote in your sig. I'm not god telling you you'll get to hell if you don't remove it or sth, I'm just a random person on the net telling you that I find it [InsertMeanWord] without any further consequences for you if you don't fit my opinion.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.
-
04-01-2007, 04:52 AM #3624Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
let's say filename is "ms0:/PSP/test" for exampleCode:strcat ( temp , filename ); strcat ( temp , "/" ); sceIoMkdir(temp, 0777);
why doesnt this work? (it doesnt make the folder test)
-
04-01-2007, 05:22 AM #3625It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I don't think you're supposed to end the filename with a slash.
Check the return value of sceIoMkdir.
-
04-01-2007, 05:37 AM #3626Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
aargh,oke that was stupid of me thnx
-
04-01-2007, 05:55 AM #3627QJ Gamer Blue
- Registriert seit
- Mar 2007
- Ort
- Holland..
- Beiträge
- 154
- Points
- 4.022
- Level
- 40
- Downloads
- 0
- Uploads
- 0
i am busy creating a nice menu; and now i want it to give it some nice color's i know how but it's a hell of job..
it's
pspDebugScreenSetTextColo r(0000CD); for the
printf(" ->");
pspDebugScreenSetTextColo r(FF0000);
printf(" menu option 1\n");
pspDebugScreenSetTextColo r(7FFF00);
printf(" menu option 2\n");
printf(" menu option 3\n");
printf(" menu option 4\n");
just for this with color's of:
-> menu option 1
menu option 2
menu option 3
menu option 4
is there any way i can make this easyier?
like printf("menu option 2",blue);?
and printf(" ->",geen);
could somehelp me with this?
-
04-01-2007, 06:32 AM #3628It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes, it's that easy.Code:#define GREEN 0x00ff00 #define BLUE 0x0000ff /*et cetera*/ int menuPrintf(char *string, u32 color) { pspDebugSetTextColor(color); return printf("%s",string); }
-
04-01-2007, 06:36 AM #3629QJ Gamer Blue
- Registriert seit
- Mar 2007
- Ort
- Holland..
- Beiträge
- 154
- Points
- 4.022
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Thanks allot

-= Double Post =-
and if got 2 more question's
-I alsow want to print nickname, what is the most easy way to this?
-and how do I halt a script.. first the user has to push X continue
example:
The creating of this program is not resposible for any damage to your psp.
if you agree press START
if you don't agree press X
if (pad.Buttons & PSP_CTRL_START) {
menu();
}
else if (pad.Buttons & PSP_CTRL_CROSS) {
sceKernelExitGame();
}
else {
sceKernelSleepTread();
}
something like this, i am not sure about else ifGeändert von Kwastie (04-01-2007 um 07:34 AM Uhr) Grund: Automerged Doublepost
-
04-01-2007, 07:19 AM #3630Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
-check the sdk samples!!!!!!!
-sceKernelDelayThread(1000 000);
1000000= one second
-use code tags , thank you!


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