Relative Content

Tag Archive for cfilefreadfseek

problems with fseek and fread in C

I’m having an issue with fseek and fread. For some reason, using fseek (f, 0, SEEK_END); will not give me the end of my file, and instead go 1000 bytes farther, giving me junk data and generally being a pain…
I have checked, if I open the same file with python, f=open("filename","r"); print(len(f.read())) will give me the correct result, but using ftell() in C after the line I wrote previously will be 1000 off, and I have no idea why.
Here is the entire code for the function that is not working:

problems with fseek and fread in C

I’m having an issue with fseek and fread. For some reason, using fseek (f, 0, SEEK_END); will not give me the end of my file, and instead go 1000 bytes farther, giving me junk data and generally being a pain…
I have checked, if I open the same file with python, f=open("filename","r"); print(len(f.read())) will give me the correct result, but using ftell() in C after the line I wrote previously will be 1000 off, and I have no idea why.
Here is the entire code for the function that is not working: