Seite 336 von 340 ErsteErste ... 236 286 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 LetzteLetzte
Zeige Ergebnis 10.051 bis 10.080 von 10174

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; Zitat von SG57 In the end, doesn't this mean I could end up with, say, 40 source files each relatively ...

  
  1. #10051
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen
    In the end, doesn't this mean I could end up with, say, 40 source files each relatively small in size?
    Yes, is that a problem? (Or you can stack multiple classes in one file if you *really* want to).

    I would love to see some C++ source code of this pattern, I think I've been following something of the sort all along (as in, couldn't one say using a 3D vector class to handle storing positions/velocities/orientations a composite pattern?)
    I would use a std::map myself which makes it easier to get components from the entity container. There is an issue that you can't have more then one instance of the same component in a map structure but that is easily solvable either by design or a code solution.

    A PPT of the same pattern: http://www.gdcvault.com/play/1911/Th...t_Architecture



  2. #10052
    QJ Gamer Green
    Points: 6.371, Level: 52
    Level completed: 11%, Points required for next Level: 179
    Overall activity: 0%

    Registriert seit
    May 2009
    Ort
    In your head.
    Beiträge
    102
    Points
    6.371
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Hey guys, I was wondering, how do I underline text using C++? I am also using OSLib, so if their is a way to do it please help me xP
    [spoiler=Quotes]
    [COLOR="Red"]Before you criticize some one, walk a mile in there shoes, that way your a mile away and you have there shoes![/COLOR]

    Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.

    [COLOR="Indigo"]The man who smiles when things go wrong has thought of someone to blame it on.[/COLOR][/spoiler]


    [color=orange]Im just a dude who wants to figure out this freaking lua thing! LOL[/color]

  3. #10053
    QJ Gamer Gold
    Points: 13.372, Level: 75
    Level completed: 31%, Points required for next Level: 278
    Overall activity: 0%

    Registriert seit
    Nov 2008
    Ort
    CAD
    Beiträge
    693
    Points
    13.372
    Level
    75
    Downloads
    19
    Uploads
    4

    Standard

    Emm, you could simply use the OSlib to draw a line under your text.

  4. #10054
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Error I got upon compiling:
    make: *** No rule to make target `graphics.o', needed by `image.elf'. Stop.

    Makefile:
    Code:
    TARGET = image
    OBJS = main.o graphics.o framebuffer.o
     
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBS = -lpspgu -lpng -lz -lm
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Image
     
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    main.c:
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspcallbacks.h>
    #include <pspctrl.h>
    #include "graphics.h"
    
     
    #define drawImage blitAlphaImageToScreen
     
    PSP_MODULE_INFO("Name Of Program",0,1,1);
     
    int main() {
    	pspDebugScreenInit();
    	//pspDebugScreenClear();
    	SetupCallbacks();
    	initGraphics();	
    	SceCtrlData pad;
    	Image* background = loadImage("back.png");
    
    	drawImage(0,0,480,272,background,0,0);
    
    	flipScreen();
    	sceKernelSleepThread();
    	return 0;
    }

  5. #10055
    QJ Gamer Gold
    Points: 13.372, Level: 75
    Level completed: 31%, Points required for next Level: 278
    Overall activity: 0%

    Registriert seit
    Nov 2008
    Ort
    CAD
    Beiträge
    693
    Points
    13.372
    Level
    75
    Downloads
    19
    Uploads
    4

    Standard

    It means your graphics.c (or .cpp) doesn't exist in the current directory, you should really learn the actual (Linux) C before skipping to the PSP.

  6. #10056
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Whats the best way to make objects in C?

    Like lets say I want to make two objects:
    a player and a block

    The player has these attributes:
    - Can walk
    - Jump (gravity)
    - collides with blocks
    - contains animations / a sprite

    The block has these attributes:
    - stays stationary
    - is either jump through / not jump through
    - contains a sprite

    How would you do this? Since you can't use classes in C, and if Im not mistaken, the PSP SDK wont let you use C++

  7. #10057
    QJ Gamer Gold
    Points: 13.372, Level: 75
    Level completed: 31%, Points required for next Level: 278
    Overall activity: 0%

    Registriert seit
    Nov 2008
    Ort
    CAD
    Beiträge
    693
    Points
    13.372
    Level
    75
    Downloads
    19
    Uploads
    4

    Standard

    Zitat Zitat von Beat_Bob Beitrag anzeigen
    , and if Im not mistaken, the PSP SDK wont let you use C++
    Who's the idiot that told you that? Of course you can use C++ with the pspsdk, it's just a matter of file extension.

  8. #10058
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    indeed, c++ is fully supported, in ur makefile, simply include -lstdc++ on your library line and your fine

    also, you can use struct's in c, so that's how i'd go about it personally if i couldn't use c++(also generally you'll probably almost never find a situation where C is allowed, but c++ isn't, and vice versa
    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

  9. #10059
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Well I changed it to .cpp instead of .c, I also added that line on my makefile.
    I get these errors after running 'make' :
    Code:
    psp-g++ -I. -ID:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -ID:/pspsdk/psp/sdk/i
    clude -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150   -c -o mai
    .o main.cpp
    main.cpp: In function 'int main()':
    main.cpp:18: warning: unused variable 'pad'
    psp-gcc -I. -ID:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150  -L
     -LD:/pspsdk/psp/sdk/lib   main.o graphics.o framebuffer.o -lpspgu -lpng -lz -l
     -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet
    lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o image.elf
    main.o: In function `main':
    main.cpp:(.text+0x74): undefined reference to `initGraphics()'
    main.cpp:(.text+0x80): undefined reference to `loadImage(char const*)'
    main.cpp:(.text+0xa0): undefined reference to `blitAlphaImageToScreen(int, int,
    int, int, Image*, int, int)'
    main.cpp:(.text+0xa8): undefined reference to `flipScreen()'
    collect2: ld returned 1 exit status
    make: *** [image.elf] Error 1
    main.cpp:
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspcallbacks.h>
    #include <pspctrl.h>
    #include "graphics.h"
    
    //
     
    #define drawImage blitAlphaImageToScreen
     
    PSP_MODULE_INFO("Name Of Program",0,1,1);
     
    int main() {
    	pspDebugScreenInit();
    	//pspDebugScreenClear();
    	SetupCallbacks();
    	initGraphics();	
    	SceCtrlData pad;
    	Image* background = loadImage("back.png");
    
    	drawImage(0,0,480,272,background,0,0);
    
    	flipScreen();
    	sceKernelSleepThread();
    	return 0;
    }
    Makefile:
    Code:
    TARGET = image
    OBJS = main.o graphics.o framebuffer.o
     
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBS = -lpspgu -lpng -lz -lm -lstdc++
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Image
     
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak

  10. #10060
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    you dont need -lstdc++ so you can compile an app using graphics.h

    you should make sure you have libpng and libpspgu fallow this tut and you will have a working base code for it

    Lesson 04 - Simple Image Processing.

  11. #10061
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    I have graphics.h and graphics.c and framebuffer.c and framebuffer.h, I also have libpng installed.
    And I removed that line from my Makefile (since you said it's not needed)

    What's wrong with my code?

  12. #10062
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    main.o: In function `main':
    main.cpp:(.text+0x74): undefined reference to `initGraphics()'
    main.cpp:(.text+0x80): undefined reference to `loadImage(char const*)'
    main.cpp:(.text+0xa0): undefined reference to `blitAlphaImageToScreen(i nt, int,
    int, int, Image*, int, int)'
    main.cpp:(.text+0xa8): undefined reference to `flipScreen()'
    collect2: ld returned 1 exit status
    make: *** [image.elf] Error 1
    thats your problem the functions in your graphics.h and .c files are not being recognized

    also change your main.cpp to just main.c and make sure are in the same folder as the makefile

  13. #10063
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    But they're in the same directory as my main.cpp file..........

  14. #10064
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Wonder why it isnt working

  15. #10065
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von lilmnm Beitrag anzeigen
    thats your problem the functions in your graphics.h and .c files are not being recognized

    also change your main.cpp to just main.c and make sure are in the same folder as the makefile
    the extension has nothing to do with it

    beat_bob, the error is because the program doesn't see those functions, your makefile looks good, so i'm not certain why it's complaining

    hmm, i wonder, unlikly, but try:

    Code:
    TARGET = image
    OBJS = framebuffer.o graphics.o main.o
     
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBS = -lpspgu -lpng -lz -lm -lstdc++
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Image
     
    	PSPSDK=$(shell psp-config --pspsdk-path)
    	include $(PSPSDK)/lib/build.mak
    i doubt it'll 100% work, but give that a shot
    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

  16. #10066
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    GNU GCC recognizes .C, .cc, .cpp, .CPP, .c++, .cp, .cxx as C++ files and will use C++ compilation regardless of whether you invoke it through gcc (C) or g++ (C++).

    Note the .C - that is a capital C, the case matters in GCC. .c is a C file whereas .C is a C++ file (if you let the compiler decide what it is compiling based of file extension that is).

    Beat_Bob, you are compiling your main source file as C++ which is fine but you're including a C source file (graphics.h).

    You need to either rename main.cpp to main.c to force the compiler to compile it as C (not C++ so it can include the graphics C source file)

    OR

    Tell the compiler in your C++ source code that you are including a C source file
    Code:
    extern "C"
    {
      #include "graphics.h"
    }
    I recommend just renaming main.cpp to main.c and removing -lstdc++ from your libs line. You are not programming in C++ (yet) and you're using a C graphics library.

    ...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


  17. #10067
    QJ Gamer Gold
    Points: 13.372, Level: 75
    Level completed: 31%, Points required for next Level: 278
    Overall activity: 0%

    Registriert seit
    Nov 2008
    Ort
    CAD
    Beiträge
    693
    Points
    13.372
    Level
    75
    Downloads
    19
    Uploads
    4

    Standard

    Does anyone know how to remove an image from the screen (not de-allocating it) without using flags?

  18. #10068
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von mootjeuh Beitrag anzeigen
    Does anyone know how to remove an image from the screen (not de-allocating it) without using flags?
    don't draw it in the next frame?
    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

  19. #10069
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    Zitat Zitat von slicer4ever Beitrag anzeigen
    the extension has nothing to do with it

    beat_bob, the error is because the program doesn't see those functions, your makefile looks good, so i'm not certain why it's complaining

    hmm, i wonder, unlikly, but try:

    Code:
    TARGET = image
    OBJS = framebuffer.o graphics.o main.o
     
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBS = -lpspgu -lpng -lz -lm -lstdc++
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = Image
     
    	PSPSDK=$(shell psp-config --pspsdk-path)
    	include $(PSPSDK)/lib/build.mak
    i doubt it'll 100% work, but give that a shot
    he already had his makefile like that the order of the objects dont matter but after making changes just to be sure you should clean the source by typing "make clean" because its showing an error in the main.o file with the error code such as this from his earlier post

    main.o: In function `main':
    main.cpp.text+0x74): undefined reference to `initGraphics()'
    main.cpp.text+0x80): undefined reference to `loadImage(char const*)'
    main.cpp.text+0xa0): undefined reference to `blitAlphaImageToScreen(i nt, int,
    int, int, Image*, int, int)'
    main.cpp.text+0xa8): undefined reference to `flipScreen()'
    collect2: ld returned 1 exit status
    make: *** [image.elf] Error 1
    this could help get rid of those errors cause it tries to compile the main.o files already made to save time on compiling

  20. #10070
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    i was fairly certain changing the order wouldn't matter, i do agree a make clean may solve it, otherwise i don't see an issue with the makefile, i checked the graphics.h that he was linked to in another thread, it has the appropiate functions listed, and defined, so i'm not sure of the issue
    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

  21. #10071
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    Zitat Zitat von slicer4ever Beitrag anzeigen
    i was fairly certain changing the order wouldn't matter, i do agree a make clean may solve it, otherwise i don't see an issue with the makefile, i checked the graphics.h that he was linked to in another thread, it has the appropiate functions listed, and defined, so i'm not sure of the issue
    same it could be that he may have changed names of the funtions in the graphics. h and stuff or something like that

  22. #10072
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    I used SG57's method using extern C, and it worked!

    Thanks!

  23. #10073
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen

    I recommend just renaming main.cpp to main.c and removing -lstdc++ from your libs line. You are not programming in C++ (yet) and you're using a C graphics library.
    as i said before and it was the cure :P

  24. #10074
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    i swear i've used c and cpp files without externing them, w/e
    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

  25. #10075
    QJ Gamer Green
    Points: 2.003, Level: 27
    Level completed: 2%, Points required for next Level: 147
    Overall activity: 0%

    Registriert seit
    Jun 2009
    Beiträge
    61
    Points
    2.003
    Level
    27
    Downloads
    0
    Uploads
    0

    Standard char/double ore string with printtextscreen

    I was wondering how should i use a doucle (%d) with printtextscreen (graphics.h) like
    Code:
    printf("%d", scePowerGetCpuClockFrequency());

  26. #10076
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    Zitat Zitat von LegendMythe Beitrag anzeigen
    I was wondering how should i use a doucle (%d) with printtextscreen (graphics.h) like
    Code:
    printf("%d", scePowerGetCpuClockFrequency());
    because the way scePowerGetCpuClockFreque ncy(); was set up was to return the cpu to a buffer or t fill in the variable and %d is the variable that is being represented in the printf because we dont know what the CPU speed is so we find out what it is then return it to the variable


    the way you should use it is by

    Code:
    int CPUClock[17]; //buffer to save the info
    sprintf(CPUclock, "CPU: %d", scePowerGetCpuClockFrequency()); //Only prints out the CPU speed i.e. 333 or 222
    A better way is to show both the CPU speed and the BUS speed and heres how
    Code:
    int CPUClock[17]; //buffer to save the info
    //this following line will print out the CPU and the BUS speed i.e. 333/166 or 222/111
    sprintf(CPUclock, "CPU/BUS: %d/%d", scePowerGetCpuClockFrequency(), scePowerGetBusClockFrequency());
    Dont forget to add #include <psppower.h> to the main.c and or main.h if you have one for the cpu stuff and add
    -lpsppower to the LIBS = line in your make file

    hope i explained it clearly enough if it doesn't make any sense then ask another question and ill clarify it
    Geändert von lilmnm (04-14-2010 um 11:22 AM Uhr)

  27. #10077
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    lilmnm - Your CPUClock array of integers ought to be an array of characters.

    Code:
    char CPUClock[17]; //buffer to save the info
    sprintf(CPUclock, "CPU: %d", scePowerGetCpuClockFrequency());
    and snprintf for buffer overflow protection :)
    Code:
    char CPUClock[17]; //buffer to save the info
    //this following line will print out the CPU and the BUS speed i.e. 333/166 or 222/111
    snprintf(CPUclock, 17, "CPU/BUS: %d/%d", scePowerGetCpuClockFrequency(), scePowerGetBusClockFrequency());

    ...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


  28. #10078
    Developer
    Points: 8.092, Level: 60
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    Grand Rapids! MI
    Beiträge
    125
    Points
    8.092
    Level
    60
    Downloads
    5
    Uploads
    2

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen
    lilmnm - Your CPUClock array of integers ought to be an array of characters.

    Code:
    char CPUClock[17]; //buffer to save the info
    sprintf(CPUclock, "CPU: %d", scePowerGetCpuClockFrequency());
    and snprintf for buffer overflow protection :)
    Code:
    char CPUClock[17]; //buffer to save the info
    //this following line will print out the CPU and the BUS speed i.e. 333/166 or 222/111
    snprintf(CPUclock, 17, "CPU/BUS: %d/%d", scePowerGetCpuClockFrequency(), scePowerGetBusClockFrequency());
    lol the buffer is big enough so there wouldnt be an over flow its basically the same way i have it set up in my DayPR and im not having any troubles with it but good add though its better to be safe then sorry i guess lol also i havent seen the snprintif function anywhere what file is it in in the SDK?

  29. #10079
    QJ Gamer Green
    Points: 3.606, Level: 37
    Level completed: 71%, Points required for next Level: 44
    Overall activity: 99,0%

    Registriert seit
    Jul 2007
    Beiträge
    88
    Points
    3.606
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Nevermind, works.
    Geändert von Beat_Bob (04-14-2010 um 06:51 PM Uhr)

  30. #10080
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    lilmnm - It isn't part of the SDK, it is part of stdlib. Its not that it 'will' overflow, its just a good habit and to be consciously aware of what might happen.

    Practical use: I used a 256 long buffer for a texture filepath that ended up being like 300 characters long after all was done with it from the relative sub-directories. I couldn't figure out 'why' it was failing to load until I realized it was cutting off the final few chars of the filename. If I hadn't of used snprintf, it would've been a buffer overflow with undefined behavior. Instead I simply printed the buffer out to the debug stream and sure enough I saw it was missing the last half of the filename. Then I simply upped the buffer to 400 in size.

    ...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



 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:15 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .