The fread function fread
returns the number of bytes actually read. So if the number of bytes read is lower that the number of bytes to be read, you are likely at the end of file.
Furthermore the feof
function will also tell you if you are at the end of the file.
To find out the size of the file without actually reading it:
long Size;
FILE *p;
p = fopen("filename.format","rb");
fseek (p, 0 , SEEK_END);
Size = ftell (p) ;
rewind (p);