On Apr 7, 11:47 pm, Richard Heathfield <r...@see.sig.invalidwrote:
2005 said:
<snip>
I do have several books - I saw a code online with EOF when reading
from a file.
That's why
I read the book too but would like a crisp answer
K&R2 provides a crisp answer on page 16.
I have K&R - not sure if there had been a "2"
EOF - a distinctive value when there is no more input, a value that
cannot be confused with any real character. This value is called
EOF, for ``end of file''.
FILE *in = fopen("myfile.txt", "r"); // Open myfile.txt read-only
while((myChar=fgetc(in)) != EOF) {
---------
---
feof is to distinguish between cases where a stream operation has
reached the end of a file and cases where the "EOF" (End Of File)
error message has simply been returned as a default error message,
without the end of the file actually being reached.
while(!feof(my_file)) {
/* [...End of file not reached, do something with it...] */
}
-----
--
So what is the difference when it comes to application?