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; Alright, one more n00b file browsing question, the Current Directory is represented as "current_dir" and the current selection is represented ...
-
05-18-2007, 09:17 PM #4531QJ 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
Alright, one more n00b file browsing question,
the Current Directory is represented as "current_dir" and the current selection is represented as, "gameEntry[current_selection].name" . My question is how would i combined them?
Like if current_dir is "ms0:/PSP/MUSIC/" and gameEntry[current_selection].name is "BatCountry.mp3", how would you put them together? like "ms0:/PSP/MUSIC/BatCountry.mp3" ?
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
05-18-2007, 11:44 PM #4532Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Code:char filePath[200]; strcpy(filePath , current_dir); strcat(filePath , gameEntry[current_selection].name);
-
05-19-2007, 12:46 AM #4533QJ 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
Thank you :)
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
05-19-2007, 01:46 AM #4534words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
BS - Make sure you use the safe versions of those functions
Better yet, you may simplify these into 2 linesCode:char filePath[200]; strncpy(filePath , sizeof(filePath)-1 , current_dir); strncat(filePath , sizeof(filePath)-1 , gameEntry[current_selection].name);
Code:char filePath[256]; snprintf(filePath,sizeof(filePath)-1,"%s%s",current_dir,gameEntry[current_selection].name);

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
05-19-2007, 02:18 AM #4535Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
mayby explain why my method is bad , because it 100 procent works
-
05-19-2007, 02:48 AM #4536
Zitat von hallo007
he didn't say bad, he said his method was safe, implying your method is unsafe. I'd like to know too as i use flash agent quite often
-
05-19-2007, 03:19 AM #4537Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
he said BS , wich stand for ... ( I am not going to say it otherwhise i get banned again)
and flash agents doenst have problems with that anyway , when i test it , i write all path's it uses to a text file (kind of debug console) and it was all correct;)
-
05-19-2007, 05:32 AM #4538Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
ow , lol
-
05-19-2007, 05:43 AM #4539QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
strcpy can easily buffer overrun. Eg
With strncpy, you have to specify the number of characters you want to copy. Normally this is the size of the buffer.Code:char buffer[12] = ""; strcpy( buffer, "hello world!" ); // Dangerous, buffer overrun
C++ (or even better, use STL strings)
CCode:const int BUFFER_SIZE = 12; char buffer[BUFFER_SIZE] = ""; strncpy( buffer, "Hello World!", BUFFER_SIZE-1 ); // buffer only contains "Hello World"
-= Double Post =-Code:#define BUFFER_SIZE 12 char buffer[BUFFER_SIZE] = ""; strncpy( buffer, "Hello World!", BUFFER_SIZE-1 ); // buffer only contains "Hello World"
Here is my exact lib line in my IDE setup. Bare in mind that build.mak includes some of these libraries:
Zitat von MiG
Code:-lstdc++ -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel
Geändert von yaustar (05-19-2007 um 05:45 AM Uhr) Grund: Automerged Doublepost
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-19-2007, 08:20 AM #4540QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
thanks, but it still complains everywhere string is used.
Zitat von yaustar
is it ok to use the include <string> ?
-
05-19-2007, 08:50 AM #4541QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes it is. What errors are you getting? Are you using the correct namespace? What does you current test code look like.
Zitat von MiG
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-19-2007, 09:53 AM #4542QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
****...
Zitat von yaustar
forgot the old using namespace std;
What a mug i feel like...
-
05-19-2007, 11:57 AM #4543QJ 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
lol, thanks to my "C++ for dummies" book i bought the other day, i under stood that :P
Zitat von yaustar
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
05-19-2007, 12:22 PM #4544QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
blackshark r they paying u to advertise that book?.....jk=-)
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
-
05-19-2007, 12:54 PM #4545QJ 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
lol, no but since I learned useful stuff from it i just feel obligated to it :P
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
05-19-2007, 02:49 PM #4546QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Ugh. My mind is being retarted today.
Can some1 tell me how to call a image to the screen (my image is was a 16 bit, but i converted it to C.) I'm trying to figure it out, but I got's a blond moment right now.
I feel embarressed askin an easy question :P
-
05-19-2007, 03:00 PM #4547words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Blond's (I being one) can at least make sense MrChaos ;) You want to load an image, but not from an external image. Rather, from an unsigned char array. If so, use bin2c, or GIMP and convert your image to an unsigned char array and point the Image *data to it.

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
05-19-2007, 03:02 PM #4548QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
That's what I did, but does it make it appear on the screen? (See, today I don't understand anything on coding...that's rare) :)
Zitat von SG57
-
05-19-2007, 03:06 PM #4549QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Do you mean that you used bin2c? Is so, instead of loading an image using graphics.c, set your images manually. (Just make sure that if the width/height are odd, add one to it. It needs to be a multiple of two.)
If you just need to load an image,Code:Image* img; img->imageWidth = /* real image width */; img->imageHeight = /* real image height */; img->textureWidth = /* real width (+1 if odd) */; img->textureHeight = /* real height (+1 if odd) */; img->data = /* variable image created with bin2c */; blitAlphaImageToScreen(0, 0, img->imageWidth, img->imageHeight, img, 0, 0);
Code:Image* img = loadImage("./myImage.png"); blitAlphaImageToScreen(0, 0, img->imageWidth, img->imageHeight, img, 0, 0);
-
05-19-2007, 03:08 PM #4550QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Oo ok thank you. The first code is what I was trying to figure out.
Zitat von PSPJunkie_
-
05-19-2007, 03:11 PM #4551QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
I figured that out after I posted it, but it took me a good minute to type that up. :)
-
05-19-2007, 04:23 PM #4552QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Now I tryed what PSPJUNKIE_ told me to, but it's coming up with compiler errors.
This is the part of the code with the errors:
The compiling errors are:Code:Image* logo; logo->imageWidth = 470; logo->imageHeight = 272; logo->textureWidth = 471; logo->textureHeight = 272; logo->data = /* I would put data here, but it would be too big. */
main.cpp:46: error: expected constuctor, destructor, or type conversion befor '->' token.
main.cpp:47: error: expected constuctor, destructor, or type conversion befor '->' token.
main.cpp:48: error: expected constuctor, destructor, or type conversion befor '->' token.
main.cpp:49: error: expected constuctor, destructor, or type conversion befor '->' token.
main.cpp:50: error: expected constuctor, destructor, or type conversion befor '->' token.
Yeah. I think I'm missing something (no duh?) I think it's classes, but I'm not sure.
-
05-19-2007, 04:28 PM #4553It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Change
toCode:Image* logo;
(Well, actually, new Image() probably takes two parameters, width and height.)Code:Image *logo = new Image();
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-19-2007, 04:33 PM #4554QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Tried it, but it came up with the same errors.
Zitat von Archaemic
-
05-19-2007, 04:36 PM #4555QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Trying changing all of the '->' to '.' (Periods).
-
05-19-2007, 04:39 PM #4556QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Weird. Still not compiling.
Zitat von PSPJunkie_
Just to make sure, do I have to create a "logo" class before I do that? Because I didn't if thats the problem.
EDIT: I created a logo class, and it still comes up with the same errors.
-
05-19-2007, 04:42 PM #4557It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
That wouldn't fix it. That's definitely a pointer to an object, and not an object in and of itself. Hence you'd use ->
Zitat von PSPJunkie_
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-19-2007, 04:45 PM #4558QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Yeah, but neither one works, lol.
Zitat von Archaemic
-
05-19-2007, 04:46 PM #4559QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Have you #include the head that defines the Image struct?
Zitat von MrChaos
(regardless, the code will crash even if it does compile).[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-19-2007, 04:48 PM #4560QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
No I havent, but let me see if that is the problem.
Zitat von yaustar
(Why would it crash?)


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