Seite 83 von 340 ErsteErste ... 33 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 133 183 ... LetzteLetzte
Zeige Ergebnis 2.461 bis 2.490 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; Ok i've been going over it and over it, looks good but I can't find out whats wrong with the ...

  
  1. #2461
    QJ Gamer Blue
    Points: 8.686, Level: 62
    Level completed: 79%, Points required for next Level: 64
    Overall activity: 45,0%

    Registriert seit
    Jan 2006
    Ort
    CO
    Beiträge
    150
    Points
    8.686
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard psp-programming lesson5

    Ok i've been going over it and over it, looks good but I can't find out whats wrong with the source maybe someone could tell me.
    Spoiler for code:
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspctrl.h>
    #include <stdio.h>
    #include <psppower.h>

    #include "graphics.h"

    PSP_MODULE_INFO("Backgrou nd Changer",0,1,1);

    #define RGB(r,g,b) ((r) \ ((g)<<8) \ ((b)<<16))

    int exit_callback(int arg1, int arg2, void *common){
    sceKernelExitGame();
    return 0;
    }

    int CallbackThread(SceSize args, void *argp) {
    int cbid;

    cbid = sceKernelCreateCallback(" Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCall back(cbid);

    sceKernelSleepThreadCB();

    return 0;
    }

    int SetupCallbacks(void) {
    int thid = 0;

    thid = sceKernelCreateThread("up date_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if(thid >= 0) {
    sceKernelStartThread(thid , 0, 0);
    }

    return thid;
    }

    int main(void){
    scePowerSetClockFrequency (333, 333, 166);
    SetupCallbacks();
    initGraphics();

    SceCtrlData pad;

    int i;
    int selComponent = 0;
    char filler[10];

    int bgR = 0;
    int bgG = 0;
    int bgB = 0;

    Color highlightColor = RGB(200, 200, 200);
    Color dimmedColor = RGB(100, 100, 100);
    Color shadowColorH = RGB(55, 55, 55);
    Color shadowColorD = RGB(55, 55, 55);

    while(1){
    sceCtrlReadBufferPositive (&pad, 1);
    if(pad.Buttons & PSP_CTRL_UP){
    if(selComponent > 0){
    selComponent--;
    }
    for(i=0; i<10; i++){
    sceDisplayWaitVblankStart ();
    }
    } else if(pad.Buttons & PSP_CTRL_DOWN){
    if(selComponent < 2){
    selComponent++;
    }
    for(i=0; i<10; i++){
    sceDisplayWaitVblankStart ();
    }
    }
    if(pad.Buttons & PSP_CTRL_RIGHT){
    switch(selComponent){
    case 0:
    bgR++;
    break;
    case 1:
    bgG++;
    break;
    case 2:
    bgB++;
    break;
    default:
    //Should Never Execute
    break;
    }
    }else if(pad.Buttons & PSP_CTRL_LEFT){
    switch(selComponent){
    case 0:
    bgR--;
    break;
    case 1:
    bgG--;
    break;
    case 2:
    bgB--;
    break;
    default:
    //Should Never Execute
    break;
    }
    }

    if(bgR < 0){
    bgR = 0;
    } else if(bgR > 255){
    bgR = 255;
    }
    if(bgG < 0){
    bgG = 0;
    } else if(bgG > 255){
    bgG = 255;
    }
    if(bgB < 0){
    bgB = 0;
    } else if(bgB > 255){
    bgB = 255;
    }
    fillScreenRect(RGB(bgR, bgG, bgB), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    sprintf(filler, "RED: %i", bgR);
    if(selComponent == 0){
    printTextScreen(11, 10, filler, shadowColorH);
    printTextScreen(10, 10, filler, highlightColor);
    }else{
    printTextScreen(11, 10, filler, shadowColorD);
    printTextScreen(10, 10, filler, dimmedColor);
    }
    sprintf(filler, "GREEN: %i", bgG);
    if(selComponent == 1){
    printTextScreen(11, 20, filler, shadowColorH);
    printTextScreen(10, 20, filler, highlightColor);
    }else{
    printTextScreen(11, 20, filler, shadowColorD);
    printTextScreen(10, 20, filler, dimmedColor);
    }
    sprintf(filler, " BLUE: %i", bgB);
    if(selComponent == 2){
    printTextScreen(11, 30, filler, shadowColorH);
    printTextScreen(10, 30, filler, highlightColor);
    }else{
    printTextScreen(11, 30, filler, shadowColorD);
    printTextScreen(10, 30, filler, dimmedColor);
    }
    flipScreen();

    for(i=0; i<1; i++){
    sceDisplayWaitVblankStart ();
    }
    }
    return 0;
    }

    my compiler output errors are
    Spoiler for errors:
    Compiler: Default compiler
    Executing make...
    make.exe -f "makefile" all
    psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o main.c
    main.c : In function 'main':
    main.c(55) : error: stray '\' in program
    main.c(55) : error: called object '200' is not a function
    main.c(55) : error: stray '\' in program
    main.c(56) : error: stray '\' in program
    main.c(56) : error: called object '100' is not a function
    main.c(56) : error: stray '\' in program
    main.c(57) : error: stray '\' in program
    main.c(57) : error: called object '55' is not a function
    main.c(57) : error: stray '\' in program
    main.c(58) : error: stray '\' in program
    main.c(58) : error: called object '55' is not a function
    main.c(58) : error: stray '\' in program
    main.c(124) : error: stray '\' in program
    main.c(124) : error: called object 'bgR' is not a function
    main.c(124) : error: stray '\' in program
    make: *** [main.o] Error 1
    Execution terminated

    This is driving me crazy and I'm sure it will turn out to be something simple...I just know it. :Argh:



  2. #2462
    QJ Gamer Bronze
    Points: 7.047, Level: 55
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Beiträge
    144
    Points
    7.047
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    #define RGB(r,g,b) ((r) \ ((g)<<8) \ ((b)<<16))
    Division bar is in the wrong direction.... =_=''
    \ = BACKSLASH -> escape character.
    / = SLASH -> division

  3. #2463
    QJ Gamer Blue
    Points: 8.686, Level: 62
    Level completed: 79%, Points required for next Level: 64
    Overall activity: 45,0%

    Registriert seit
    Jan 2006
    Ort
    CO
    Beiträge
    150
    Points
    8.686
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    lol...you helped me again. Man Im not cut and pasteing but thats the way it is in the tutorial. I cant beleave I didnt think about that because of useing \n with strings and all. GEZZ!

    Ok found out it should be pipes (shift+\), I was wondering cause dividing there doesnt make sence.
    Geändert von HYde (01-05-2007 um 12:22 AM Uhr)

  4. #2464
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    how do you read and print the bytes of an file?(print is not a problem;))

    find it;)
    (here http://www.psp-programming.com/code/...lesize_example)
    -= Double Post =-
    some warnings
    Code:
    filebrowser/file_browser.c: In function 'checkspace':
    filebrowser/file_browser.c:117: warning: passing argument 1 of 'stat' makes poin
    ter from integer without a cast
    filebrowser/file_browser.c:118: warning: format '%d' expects type 'int', but arg
    ument 2 has type 'off_t'
    filebrowser/file_browser.c:121: warning: 'return' with a value, in function retu
    rning void
    the code
    Code:
    void checkspace()
    {
    	struct stat fileStats;
    
    	if (stat(current_selection, &fileStats) == 0) {
    		printf("File size is %d\n", fileStats.st_size);
    	}
    
    	return(0);
    }
    Geändert von hallo007 (01-05-2007 um 02:51 AM Uhr) Grund: Automerged Doublepost

  5. #2465
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    blargh, I made a function to free a linked list, but it keeps crashing..

    Code:
    typedef struct ObjectList {
        Model *m;
        float x, y, z;
        float rx, ry, rz;
        ObjectList *next;
    };
    
    void WipeObjectList(ObjectList *p)
    {
         if(p == 0) return;
         if(p->next != 0)
              WipeObjectList(p->next);
         free(p);
    }
    Every "line" of the list have been allocated using malloc. I bet theres some simple reason for it crashing, but I just can't find anything wrong.


  6. #2466
    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

    Code:
    if(p->next != 0)
    Most likely this is the probem. When you create a new ObjectList struct, do you assign 'next' NULL or 0?

  7. #2467
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    how do you read and print the bytes of an file?(print is not a problem;))

    find it;)
    (here http://www.psp-programming.com/code/...lesize_example)
    -= Double Post =-
    some warnings
    Code:
    filebrowser/file_browser.c: In function 'checkspace':
    filebrowser/file_browser.c:117: warning: passing argument 1 of 'stat' makes poin
    ter from integer without a cast
    filebrowser/file_browser.c:118: warning: format '%d' expects type 'int', but arg
    ument 2 has type 'off_t'
    filebrowser/file_browser.c:121: warning: 'return' with a value, in function retu
    rning void
    the code
    Code:
    void checkspace()
    {
    	struct stat fileStats;
    
    	if (stat(current_selection, &fileStats) == 0) {
    		printf("File size is %d\n", fileStats.st_size);
    	}
    
    	return(0);
    }
    still not fixed:s

  8. #2468
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    Code:
    if(p->next != 0)
    Most likely this is the probem. When you create a new ObjectList struct, do you assign 'next' NULL or 0?
    0.

    I thought NULL was defined to be 0 though? Maybe I were lied to.

    anyway, shortened version of my code for makeing a new list is;

    Code:
    void AddObject2List(ObjectList *p)
    {
         if(p->next == 0)
         {
              p->next = (ObjectList*) malloc(sizeof(ObjectList));
              p = p->next;
              p->next = 0;
         }
         else
         {
              AddObject2List(p->next);
         }
    }


  9. #2469
    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

    I thought NULL was defined to be 0 though? Maybe I were lied to.
    Not always, always prefer NULL over 0.

    Can you post up some sample code using your list strcut and all the functions that you use. That way I can debug it properly on my machine.

  10. #2470
    QJ Gamer Silver
    Points: 8.201, Level: 61
    Level completed: 17%, Points required for next Level: 249
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Sheffield, UK
    Beiträge
    844
    Points
    8.201
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    still not fixed:s
    void functions dont return anything :)

  11. #2471
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    yeah i know that warniung ofcourse;)

    but the other warnings , any idea?

  12. #2472
    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

    Code:
    void checkspace()
    {
    	struct stat fileStats;
    
    	if (stat(current_selection, &fileStats) == 0) {
    		printf("File size is %d\n", fileStats.st_size);
    	}
    
    	return(0);
    }
    void functions don't need a return value.
    You need to type cast fileStats.st_size to an integer.
    You have both a struct and a function named exactly the same thing. Very bad design.
    stat function's first parameter is expecting a pointer not an integer.

  13. #2473
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    Not always, always prefer NULL over 0.

    Can you post up some sample code using your list strcut and all the functions that you use. That way I can debug it properly on my machine.
    functions: http://www.freewebs.com/waterbottle123/excode.c

    code:
    AddObjects2List( 0, 0, 0, 0, 0, -32, 0, 0, 6, Asphalt, rootGround );//add 6 lines to the list.

    pspDebugScreenPrintf("%d" , CountList(rootGround)); //prints amount of lines

    if(pad.Buttons & PSP_CTRL_START) WipeObjectList(rootGround->next); //crashes

    edit: also Asphalt is a Model,
    Code:
    typedef struct {
        Vertextex *o;
        CTGATexture *tex;
        int size;
        int type;
        float sx, sy, sz;
        float maxdist;
    } Model;


  14. #2474
    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

    Code:
    #include <stdlib.h>
    
    typedef struct ObjectList {
        float x, y, z;
        float rx, ry, rz;
        ObjectList *next;
    };
    
    //Fills a line in an ObjectList.
    void AO2L( float x, float y, float z, float rx, float rz, ObjectList *p )
    {
         p->x = x;
         p->y = y;
         p->z = z;
         p->rx = rx;
         p->rz = rz;
         p->next = NULL;
    }
    
    //Adds new lines to an ObjectList, and fills them.
    void AddObjects2List( float sx, float sy, float sz, float dx, float dy, float dz, float rx, float rz, int amt, ObjectList *p )
    {
         if(p->next == NULL)
         {
              p->next = (ObjectList*) malloc(sizeof(ObjectList));
              p = p->next;
              AO2L( sx+=dx, sy+=dy, sz+=dz, rx, rz, p );
              amt--;
              if(amt>0)
                 AddObjects2List( sx, sy, sz, dx, dy, dz, rx, rz, amt, p );
         }
         else
         {
              AddObjects2List( sx, sy, sz, dx, dy, dz, rx, rz, amt, p->next );
         }
    }
    
    void WipeObjectList(ObjectList *p)
    {
         if(p == NULL) return;
         if(p->next != NULL)
              WipeObjectList(p->next);
         free(p);
    }
    
    int CountList(ObjectList *p)
    {
        int counter = 0;
        while(p != NULL)
        {
           counter++;
           p = p->next;
        }
        return counter;
    }
    
    int main( )
    {
        ObjectList *rootGround = (ObjectList*) malloc(sizeof(ObjectList));
        rootGround->next = NULL;
        AddObjects2List( 0, 0, 0, 0, 0, -32, 0, 0, 6, rootGround );
        WipeObjectList(rootGround ->next);
        return 0;
    }
    Works fine for me. No crashes.

  15. #2475
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    Works fine for me. No crashes.
    Weird.. :/


  16. #2476
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    How to copy a file ?

  17. #2477
    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 psphacker12.
    How to copy a file ?
    You google:
    http://www.google.co.uk/search?q=fop...en-US:official

    First hit:
    http://www.macdonald.egate.net/CompSci/hfileio.html

  18. #2478
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    thx yaustar

  19. #2479
    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

    psp - The time it took you to type up and post that question, then waiting, could have been spent implementing the file copying after a quick google... Try it next time ;) Its much faster and doesnt make you look like you're depending on others (hint)

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


  20. #2480
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    how do you write your own files to flash1?? i can only write teh registery files and i want to flash a mp3 to it
    evertime i try it loads the mp3 but dont flash it:s

    any sugestions?

  21. #2481
    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

    You write correctly using 3rd grade punctuation and spelling skills...

    Consult Art for a working answer...

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


  22. #2482
    Developer
    Points: 10.075, Level: 67
    Level completed: 7%, Points required for next Level: 375
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    Sweden
    Beiträge
    941
    Points
    10.075
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    how do you write your own files to flash1?? i can only write teh registery files and i want to flash a mp3 to it
    evertime i try it loads the mp3 but dont flash it:s

    any sugestions?
    You probably will have to mount flash1 like flash0.

  23. #2483
    QJ Gamer Green
    Points: 9.253, Level: 64
    Level completed: 68%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Australia - A.C.T.
    Beiträge
    1.517
    Points
    9.253
    Level
    64
    Downloads
    0
    Uploads
    0

    Standard

    is there a way i can get my psp to act like x is being pressed when i press select & note
    something like
    if (pad_data.Buttons & PSP_CTRL_SELECT & PSP_CTRL_NOTE){
    PSP_CTRL_CROSS
    }

  24. #2484
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Not without hooking some functions.

    Maybe if you explained exactly what you are trying to achieve we could offer an alternative idea.

    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

  25. #2485
    QJ Gamer Green
    Points: 9.253, Level: 64
    Level completed: 68%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Australia - A.C.T.
    Beiträge
    1.517
    Points
    9.253
    Level
    64
    Downloads
    0
    Uploads
    0

    Standard

    basicly say one of your psp buttons stoped working this could be used to make a 2 buttons pressed together do what that button did befor.
    -= Double Post =-
    would this code be able to help with hooking
    http://0okm.blogspot.com/2006/11/psp...-released.html
    Geändert von mafia1ft (01-08-2007 um 09:28 PM Uhr) Grund: Automerged Doublepost

  26. #2486
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Yes. There's always RemaPSP as an alternative too.

    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

  27. #2487
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SodR
    You probably will have to mount flash1 like flash0.
    i did

  28. #2488
    QJ Gamer Green
    Points: 5.712, Level: 48
    Level completed: 81%, Points required for next Level: 38
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    USA SC/NC
    Beiträge
    699
    Points
    5.712
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    i did
    Spoiler for Copy a file to flash1:

    u8 dataOut[2000000] __attribute__((aligned(64 )));
    int copy_file(char *src, char *dst)
    {

    SceUID infd = sceIoOpen(src, PSP_O_RDONLY, 0777);
    SceUID outfd = sceIoOpen(dst, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
    int bytesread;



    while ((bytesread = sceIoRead(infd, dataOut, 8192)) > 0)
    {
    sceIoWrite(outfd, dataOut, bytesread);
    }

    sceIoClose(infd);
    sceIoClose(outfd);
    sceIoRemove(src); //Remove this if you want :P
    return 0;
    }
    ///////////////////////////////////////////////////////////////////////////

    void Flash1Assign()
    {

    if (sceIoUnassign("flash1:") < 0)
    {
    printf("!Error unassigning flash1.\n");
    }


    if (sceIoAssign("flash1:", "lflash0:0,1", "flashfat1:", IOASSIGN_RDWR, NULL, 0) < 0)
    {
    printf("!Error re-assigning flash1.\n");
    }

    }
    //////////////////////////////////////////////////////////
    //Good Stuff. Main();.
    int main(int argc, char *argv[])
    {


    pspDebugScreenInit();
    pspDebugScreenClear();
    Flash1Assign();
    copy_file("ms0:/music.mp3", "flash1:/music.mp3");
    printf("done! :)");
    return 0;
    }



    Geändert von Moca (01-12-2007 um 10:30 PM Uhr)
    [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]

  29. #2489
    QJ Gamer Blue
    Points: 8.686, Level: 62
    Level completed: 79%, Points required for next Level: 64
    Overall activity: 45,0%

    Registriert seit
    Jan 2006
    Ort
    CO
    Beiträge
    150
    Points
    8.686
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Question Program Console Window! Some close some don't.

    Some of you may know that in some Compiler IDE's, you have to tell the program your writing to wait for you. So that you can see your output.
    With C I use getchar(); "mainly for simple programs, or just in the develpoment process" What I have here is two simple programs, the first one everyone knows.

    Spoiler for Example :: Hello World:

    #include <stdio.h>

    main()
    {
    printf("Hello World!\n");

    getchar(); // To pause the console

    return 0;
    }


    Getting to my point and question
    If I compile and run Hello World it paused and waited for me to hit a key. My second example I did.

    Spoiler for Example :: Multiply two numbers:

    #include <stdio.h>

    int a, b, c;

    int product(int x, int y);

    int main()
    {
    // Input the first numbers
    printf("Enter a number between 1 and 100: ");
    scanf("%d", &a);

    // Input the second number
    printf("\nEnter another number between 1 and 100: ");
    scanf("%d", &b);

    // Calculate and display the product
    c = product (a, b);
    printf("\n%d times %d = %d\n", a, b ,c);

    // Keep console open to see result
    getchar();

    return 0;
    }

    /* Function returns the product of its two arguments */
    int product(int x, int y)
    {
    return (x * y);
    }


    When I go to run it I will enter my two numbers, but when I get the output. The console closes before I can see it. This has been bothering me all day. With no answers from goggle ...so far! I know some of you may say just to use Visual C++ or something of that nature, and it will pause it for me. Thats all good! What I have been doing lately is going through some different IDE's. Especially for use with Cygwin for PSP development. "Plus scrapping some of the rust off thats collected on my programming knowledge"

    Maybe thats just it and I'm not seeing the obvious. Maybe someone can put my mind to ease. And I hope this wasn't a waste of time. Sorry if it was, I do need some sleep! :Argh:

  30. #2490
    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

    Honestly, I would just use another scanf instead of getchar.

    I be guessing you are using DevCpp for the IDE, I personally prefer Code::Blocks myself.


 

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:14 PM Uhr.

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