Page 1 of 1
fseek problem files >2Gb (32-bit compile)
Posted: Sat Apr 20, 2019 8:50 am
by Rebel
Code: Select all
FILE *fp;
int offset;
fseek(fp,offset,SEEK_SET);
When the file is >2Gb it crashes.
Changing int offset; to:
Code: Select all
unsigned int offset;
unsigned long long offset; (64 bit in my compiler)
Doesn't help, same crash.
Is there a way out?
Re: fseek problem files >2Gb (32-bit compile)
Posted: Sat Apr 20, 2019 9:17 am
by hgm
Re: fseek problem files >2Gb (32-bit compile)
Posted: Sat Apr 20, 2019 8:24 pm
by tmokonen
Just be aware that _fseeki64 and _ftelli64 are Windows specific. I used the the more portable POSIX functions fseeko64 and ftello64 with GCC under windows successfully, although I am not sure they will work with Microsoft's compiler.
Re: fseek problem files >2Gb (32-bit compile)
Posted: Sat Apr 20, 2019 8:34 pm
by konsolas
If you're on windows, you could also switch to c++ (std::ifstream supports all this natively) or use the windows API directly (CreateFile)