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 return 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 returns 0. Then feof(FILE *)
will say "OK, now you reach the end."
Why is one more read
required and how can I determine end of file or how can I know how many bytes are left in a file stream if I don't want the feof
-style?