When I try to determine end of file with function feof(FILE *)
, I find it does not work as I expected: an extra read is required even if the stream does end. e.g. feof(FILE*)
will not tell true if invoked on a file with 10 bytes data just after reading 10 bytes out. I need an extra read operation which of course return 0, then feof(FILE *)
will say "OK, now you reach the end."
My question is why does one more read
required and how to determine end of file or how to know how many bytes left in a file stream if I don't want the feof
-style?
Thanks and Best Regards.