Seite 120 von 340 ErsteErste ... 20 70 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 170 220 ... LetzteLetzte
Zeige Ergebnis 3.571 bis 3.600 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; Guys.......i didn't post the buttons LTrigger part for asking if i need to use oldpad or not. I just did ...

  
  1. #3571
    QJ Gamer Blue
    Points: 3.642, Level: 37
    Level completed: 95%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    99
    Points
    3.642
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Guys.......i didn't post the buttons LTrigger part for asking if i need to use oldpad or not. I just did it to show the general function. I only need to test the 4th brightness, and get it working. I have enough knowledge to know about oldpad. So, i just need someone to help me with the brightness code, and not the controls code.



  2. #3572
    QJ Gamer Green
    Points: 5.795, Level: 49
    Level completed: 23%, Points required for next Level: 155
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Cape Town, South Africa
    Beiträge
    714
    Points
    5.795
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    For oldpad, I do this:

    Code:
    unsigned long keysPressed = (currentPad.Buttons ^ oldPad.Button) & currentPad.Buttons ;
    keysPressed will now give you all the keys that have just been pressed. It's simple and efficient.

    By the way, what's "int *100" supposed to do?

  3. #3573
    QJ Gamer Blue
    Points: 3.642, Level: 37
    Level completed: 95%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    99
    Points
    3.642
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Xylem
    I need some help with 4th brightness. Here is my code:
    Code:
    void sceDisplay_driver_9E3C6DC6(int 100,int 0);//a0 0-100,a1 = 0/1 (set to 0) 
    #define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6 
    void sceDisplay_driver_31C4BAA8(int *100,int *0); 
    #define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8
    
    //later in main loop
    if (pad.Buttons & PSP_CTRL_LTRIGGER){
    sceDisplayGetBrightness(int *100, int *0) 	//to get brightness, and
    sceDisplaySetBrightness(int 100, int 0)           //to set brightness
    }
    I am obviously not using the right functions or the right values. What is the code i need to use if i want to set the 4th brightness?
    Let me quote this again. For the last time, I AM NOT ASKING FOR OLDPAD OR THE CONTROLS FOR BRIGHTNESS, BUT THE FUNCTION FOR THE BRIGHTNESS. HOW IS THAT HARD TO UNDERSTAND?

  4. #3574
    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 sceDisplay_driver_9E3C6DC6(int 100,int 0);//a0 0-100,a1 = 0/1 (set to 0) 
    #define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6 
    void sceDisplay_driver_31C4BAA8(int *100,int *0); 
    #define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8
    Where the hell are you getting this code from?

  5. #3575
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Xylem
    Let me quote this again. For the last time, I AM NOT ASKING FOR OLDPAD OR THE CONTROLS FOR BRIGHTNESS, BUT THE FUNCTION FOR THE BRIGHTNESS. HOW IS THAT HARD TO UNDERSTAND?
    Code:
    if(pad.Buttons & PSP_CTRL_LTRIGGER) {
         sceDisplaySetBrightness(100,0);
    }
    Why is that so hard to understand?

  6. #3576
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    How do you set the psp debug text to a different size? / is there a way?

    Thank you
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

  7. #3577
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von BlackShark
    How do you set the psp debug text to a different size? / is there a way?
    No.
    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.

  8. #3578
    QJ Gamer Blue
    Points: 3.642, Level: 37
    Level completed: 95%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    99
    Points
    3.642
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Hey,
    Listen guys, i am very sorry about my behavior earlier. I was just pretty angry because of the bad grade at school, and i was very sensitive about that (lol, it turned out to be someone else's grade.....teacher made a mistake). Anyways, my point is that my behavior was really bad, and i was being really rude (especially to Yaustar and Access_Denied, who have helped me a lot the past days in coding). Just like to say sorry.
    Also, i have one last question. Here is the code:

    Code:
    void sceDisplay_driver_9E3C6DC6(int a0,int a1);//a0 0-100,a1 = 0/1 (set to 0) 
    #define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
    //later in main loop controls
        if(pad.Buttons & PSP_CTRL_LTRIGGER) {
            sceDisplaySetBrightness(100,0);
        }
    In that code, what do i need to change to make it work? Do i change the a0 to 100 and a1 to 0? Or do i leave that, but put the 100 and 0 in the set part like i did?
    Geändert von Xylem (03-30-2007 um 06:21 PM Uhr)

  9. #3579
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Hey, i need help with I/O functions. Right now, i am optimizing the code for the G-Pack and trying to make it look more organized and look clean. I need to put all my settings in one file. I know how to read X to Y bytes, but i don't know how to write from X to Y bytes. If anyone could explain or give me the code, then i can understand and learn it. Thanks.
    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...)

  10. #3580
    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

    fprintf(FILE *stream, const char * format, ...);

    ftw...

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


  11. #3581
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    fprintf(FILE *stream, const char * format, ...);

    ftw...
    Lol, i have no idea what you are saying....if you could give me an example code, i can understand it better. Btw, here is the code for reading the 6th to the 7th character in my g-pack:

    Code:
    char x[7];
    char variable[2] = "0";
    char variable1[2] = "1";
    FILE *credit;
    if ((credit = fopen("./files/credit.txt","rb")) == NULL)
    {
         printf("There is nothing in this file");
    }
    x[fread(x, 1, 7, credit)] = 0;
    fclose(credit);
    x[7]=0;
    if(strcmp (variable,x+6) == 0)
            {
            appmain();
            }
    if(strcmp (variable1,x+6) == 0)
            {      
            credits();
            }
    It reads the 6th to the 7th character (being the 7th character- 9999991 or 9999990). I know how to read it, but how do you write. I had another question about that, why do you need a [2] after the variables i declared. Whenever i put another number in the [-], the program doesn't work...
    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...)

  12. #3582
    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 superbatxs
    Lol, i have no idea what you are saying....if you could give me an example code, i can understand it better. Btw, here is the code for reading the 6th to the 7th character in my g-pack:

    Code:
    char x[7];
    char variable[2] = "0";
    char variable1[2] = "1";
    FILE *credit;
    if ((credit = fopen("./files/credit.txt","rb")) == NULL)
    {
         printf("There is nothing in this file");
    }
    x[fread(x, 1, 7, credit)] = 0;
    fclose(credit);
    x[7]=0;
    if(strcmp (variable,x+6) == 0)
            {
            appmain();
            }
    if(strcmp (variable1,x+6) == 0)
            {      
            credits();
            }
    It reads the 6th to the 7th character (being the 7th character- 9999991 or 9999990). I know how to read it, but how do you write. I had another question about that, why do you need a [2] after the variables i declared. Whenever i put another number in the [-], the program doesn't work...
    Example code using fprintf
    Code:
    char text[12] = "Hello World";
    FILE *d;
    if ((d = fopen("ms0:/test.txt", "a+b")) == NULL)
    {
         printf("Dest. file could not be opened for writing");
         fclose(d);
         return -1;
    }
    fprintf(d,"Just like printf but prints to file instead of screen. BTW, %s", text);
    fclose(d);
    [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]

  13. #3583
    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

    super - You need to learn to use your resources more effectively... A quick google search will give you something similar to what Moca posted.

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


  14. #3584
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Moca
    Example code using fprintf
    Code:
    char text[12] = "Hello World";
    FILE *d;
    if ((d = fopen("ms0:/test.txt", "a+b")) == NULL)
    {
         printf("Dest. file could not be opened for writing");
         fclose(d);
         return -1;
    }
    fprintf(d,"Just like printf but prints to file instead of screen. BTW, %s", text);
    fclose(d);
    Yea, but............what about using it to print numbers instead of letters, or printing to a X to Y position. How come this doesn't work:

    Code:
    char x[7];
    char variable1[2] = "0";
    credit = fopen ( "./files/credit2.txt" , "wb" );
    x[7]=0;
    fprintf (credit, x+6, variable1);
    fclose (credit);
    I am trying to write something in to the 7th character in a file.
    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...)

  15. #3585
    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 superbatxs
    Yea, but............what about using it to print numbers instead of letters, or printing to a X to Y position. How come this doesn't work:

    Code:
    char x[7];
    char variable1[2] = "0";
    credit = fopen ( "./files/credit2.txt" , "wb" );
    x[7]=0;
    fprintf (credit, x+6, variable1);
    fclose (credit);
    I am trying to write something in to the 7th character in a file.
    :|

    INSTEAD OF PRINTING TO THE SCREEN IT PRINTS TO A FILE... Do you know how to use printf :|

    Code:
    fprintf(credit,"x + 6 = %d \n variable1 = %d",x+6,variable1);
    or...
    Code:
    sprintf(text,"x + 6 = %d \n variable1 = %d",x+6,variable1);
    fprintf(credit,text);
    btw, if you want to write to an offset,
    fseek(credit,offset,SEEK_ SET);

    This goes to the offset that you want. Then write what you want from there.
    [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]

  16. #3586
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    ok, ive asked this before and it was answered so kindly by SG57, but I could not find it again, I searched for at least an hour (not exaggerated) on this thread and could not find it so, (very sorry) but here it goes.

    How do I find the last 4 characters of a file (using a filebrowser)? like how would you tell if a file is an .mp3 ?
    Thank you, and sorry for asking that twice.
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

  17. #3587
    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

    The first thing that comes to mind is fread + strcmp
    fseek(file,-4,SEEK_END); // Seeks -4 bytes from the end of the file

    Then read the four bytes with fread and store it in a string. Compare the string with "mp3" and if strcmp returns 0, they are equal.

    btw, i guess you could read the header of every file in a directory then work from there.
    Geändert von Moca (03-31-2007 um 02:20 AM 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]

  18. #3588
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Moca
    The first thing that comes to mind is fread + strcmp
    fseek(file,-4,SEEK_END); // Seeks -4 bytes from the end of the file

    Then read the four bytes with fread and store it in a string. Compare the string with "mp3" and if strcmp returns 0, they are equal.

    btw, i guess you could read the header of every file in a directory then work from there.
    Lol, believe it or not, i was asking you guys the wrong question. Sorry for all the trouble. What i actually wanted to do was write only one character in a certain place in a file (like write a 0 instead of 6 in "1234567", etc.). I learned that you need SEEK_END to set the origin where you need to replace the character. I know how to do it now, but sorry for asking you guys the wrong question. I myself was confused, and probably made you guys confused as well. :o
    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...)

  19. #3589
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von superbatxs
    Lol, believe it or not, i was asking you guys the wrong question. Sorry for all the trouble. What i actually wanted to do was write only one character in a certain place in a file (like write a 0 instead of 6 in "1234567", etc.). I learned that you need SEEK_END to set the origin where you need to replace the character. I know how to do it now, but sorry for asking you guys the wrong question. I myself was confused, and probably made you guys confused as well. :o
    Check out the functions on this page, they will greatly help you.

    http://www.psp-programming.com/code/...id=c:functions

  20. #3590
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Access_Denied
    Check out the functions on this page, they will greatly help you.

    http://www.psp-programming.com/code/...id=c:functions
    Yep, your sig is huge. Seriously, i am going to post the code in the C examples thread to help other people who need help with writing blocks of data from X to Y bytes. I got mine to work now. Hint: the origin should be changed, and same for where you want to stop (example- SEEK_END).
    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...)

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

    Code:
    PSP_USB_CONNECTION_ESTABLISHED
    what does that mean:

    that at the moment a file is transfering to psp?

    or that the psp is connected to pc?

  22. #3592
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    Code:
    PSP_USB_CONNECTION_ESTABLISHED
    what does that mean:

    that at the moment a file is transfering to psp?

    or that the psp is connected to pc?
    I think it's that the psp is connected to the pc.
    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...)

  23. #3593
    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

    oke
    Code:
    sceUsbGetState(void);
    does anyone know wich byte of the return is for currently transfering , or doesnt it returns that info?

  24. #3594
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Ok, i was wrong. I don't understand how to write X to Y bytes in a file. If anyone could help, that would be great. I tried using this:

    Code:
    char buffer20[] = { '0' };
    credit = fopen ( "./files/credit.txt" , "wb" );
    fseek(credit, 5, SEEK_END);
    fwrite(buffer20, sizeof(buffer20[0]) , sizeof(buffer20), credit);
    fclose (credit);
    I wanted to replace a 6 with 0 in "1234567". However, when i used it, it gave me "123450". It deleted the 7. I know why, because i did SEEK_END, and the program seeked from the 5 to the 7 because of it. But even when i tried "SEEK_END - 1", it still gave me the same thing. Even when i put 6 instead of SEEK_END, it still gives me a "0" in the whole file.
    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...)

  25. #3595
    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

    Try using SEEK_SET to position from the start of the file.

    The second argument of fseek is what you need to alter to get the correct value, not the third argument.

    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

  26. #3596
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Insert_Witty_Name
    Try using SEEK_SET to position from the start of the file.

    The second argument of fseek is what you need to alter to get the correct value, not the third argument.
    I tried:

    Code:
    char buffer20[] = { '0' };
    credit = fopen ( "./files/credit.txt" , "wb" );
    fseek(credit, SEEK_SET, 5);
    fwrite(buffer20, sizeof(buffer20[0]) , sizeof(buffer20), credit);
    fclose (credit);
    and:

    Code:
    char buffer20[] = { '0' };
    credit = fopen ( "./files/credit.txt" , "wb" );
    fseek(credit, 5, SEEK_SET);
    fwrite(buffer20, sizeof(buffer20[0]) , sizeof(buffer20), credit);
    fclose (credit);
    The first one gave me a "0", and the second one gave me a "123450". How do i make it so it gives me a "1234507"?
    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...)

  27. #3597
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    fseek(credit, 5, SEEK_SET);
    would seek to the offset 5 in the file.
    The other one is invalid.

    It looks to me like you're truncating the file, but I'm not sure, I've never tried to write to the middle of the file.

  28. #3598
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Archaemic
    Code:
    fseek(credit, 5, SEEK_SET);
    would seek to the offset 5 in the file.
    The other one is invalid.

    It looks to me like you're truncating the file, but I'm not sure, I've never tried to write to the middle of the file.
    So would you happen to know what to do? I have been testing and patiently waiting for someone to help for hours, and i want to finish this before i do any other optimizations to my shell.
    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...)

  29. #3599
    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

    wouldn't writing to the middle of the file overwrite whatevers written there?
    which for now you could save whatever is after that point and re-write it after writing whatever you need 2 write there
    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

  30. #3600
    QJ Gamer Bronze
    Points: 3.754, Level: 38
    Level completed: 70%, Points required for next Level: 46
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    103
    Points
    3.754
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    superbatxs

    Take a look at...

    http://www.cplusplus.com/reference/c...dio/fseek.html

    It has example and it should help,


 

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 .