(Windows) Using ftello() returns incorrect file size for "some" binary files

376 Views Asked by At

I use fseeko to move the file pointer to the file end first, then use ftello to get the binary file size. I refer to this page Do not use fseek... and follow exactly the same code in "Compliant Solution (POSIX ftello())" section.

My problem is this works fine for some binary file, but doesn't for some other binary files. I am now looking for a general way to access a binary file size.

fseeko(imageFile, 0, SEEK_END);
imageSize = ftello(imageFile);
fseeko(imageFile, 0, SEEK_SET);

I prefer to use stdio in C rather than any OS-based functions. Thanks!

0

There are 0 best solutions below