2
2005
context of a C program reading from a file?
I know its end of file but ...not sure?
I know its end of file but ...not sure?
2005 said:context of a C program reading from a file?
I know its end of file but ...not sure?
Please don't ask your real question in the subject line.
FEOF is not mentioned in the C standard.
Get yourself a decent C text book. C is not a good
language to learn by asking 20 (000) questions.
I have K&R - not sure if there had been a "2"2005 said:
K&R2 provides a crisp answer on page 16.
2005 said: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...] */
}
2005 said:I have K&R - not sure if there had been a "2"
EOF [snip]
feof is to [snip]
So what is the difference when it comes to application?
Which you might be able to finance by selling K&R1 to a collector. <G>K&R2 is the second edition. The first edition is mostly of historical
interest; it describes a largely obsolete version of the language. If
you have the first edition, invest in a copy of the second.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.