fseek vs fseeko64; whats the difference?

This is a discussion on fseek vs fseeko64; whats the difference? within the Windows Programming forums, part of the Platform Specific Boards category; I have a problem using fseeko64 this is what i have tried Code: fseek(ci.saveHandles[0],0,SEEK_END); fgetpos(ci.saveHandles[0],&curPos); // works, curPos = end ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    76

    fseek vs fseeko64; whats the difference?

    I have a problem using fseeko64
    this is what i have tried
    Code:
                fseek(ci.saveHandles[0],0,SEEK_END);
                fgetpos(ci.saveHandles[0],&curPos); // works, curPos = end of file
    Code:
                fseeko64(ci.saveHandles[0],0,SEEK_END);
                fgetpos(ci.saveHandles[0],&curPos); // does not work , curPos = 0
    Code:
                fseeko64(ci.saveHandles[0],0,SEEK_END);
                fseeko64(ci.saveHandles[0],0,SEEK_END);
                fgetpos(ci.saveHandles[0],&curPos); //works, curPos = end of file
    Code:
                clearerr(ci.saveHandles[0]);
                fseeko64(ci.saveHandles[0],0,SEEK_END);
                fgetpos(ci.saveHandles[0],&curPos); //does not work
    so something is wrong with the stream, but i dont know what. ferror returns 0 which means that there shouldnt not be anything wrong with it. Why isnt it possible to seplace all fseek's with fseeko64??



    and since im still new to the usage of 64 bit file operations, is there anything else i should now about their usage?

    (im still on winxp with mingw)
    Last edited by johny145; 08-03-2005 at 05:31 PM.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    76
    I found the solution. When a file is oped in "wb" mode the file has to be flushed before using fseeko64. fseek doesnt need a flush to work correctly

    Code:
    	FILE* myFile;
    	long long pos = 0;
    	myFile= fopen64("somefile.txt","wb");
    	fprintf(myFile,"************************");
    	//fflush(myFile); // if enabled it does work
    	fseeko64(myFile,0,SEEK_END);
    	pos = ftello64(myFile);
    Is this behaviour intentionaly? Now i have to flush after writing or before using fseeko64

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fseek failing - Error: Invalid argument
    By avi2886 in forum C Programming
    Replies: 14
    Last Post: 05-14-2009, 08:49 PM
  2. fseek() changing an unrelated variable?
    By aaronvegh in forum C Programming
    Replies: 3
    Last Post: 11-21-2007, 01:30 PM
  3. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 10:26 AM
  4. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 02:27 AM
  5. popen and fseek
    By mach5 in forum C Programming
    Replies: 4
    Last Post: 11-29-2003, 01:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21