Why is “while( !feof(file) )” always wrong? - Stack Overflow 554 TL;DR while(!feof(file)) is wrong because it tests for something that is irrelevant and fails to test for something that you need to know The result is that you are erroneously executing code that assumes that it is accessing data that was read successfully, when in fact this never happened I'd like to provide an abstract, high-level
Confusion with == EOF vs feof - Stack Overflow feof checks an end-of-file indicator set after a read that attempted to read at or past the end of file It is useful in situations where code that you don't control was reading from the file, and you want to stop the processing once the file has been exhausted
c - How to use feof (FILE *f)? - Stack Overflow 8 You should never use feof () as the exit indicator for a loop feof () is TRUE only after the end of file (EOF) is read, not when EOF is reached Source here It also explains the problem in detail and how to fix it
feof () in C file handling - Stack Overflow I am reading a binary file byte-by-byte,i need determine that whether or not eof has reached feof() doesn't works as "eof is set only when a read request for non-existent byte is made" So, I can