Re: What are the differences in EOF & FEOF in the
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 appreciate a tip.
Here's a tip, then: read more.
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Re: What are the differences in EOF & FEOF in the
On Apr 7, 11:47 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
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.t xt", "r"); // Open myfile.txt read-only
while((myChar=f getc(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?
Re: What are the differences in EOF & FEOF in the
2005 said:
<snip>
while(!feof(my_ file)) {
/* [...End of file not reached, do something with it...] */
I sometimes despair of humanity.
while(file-reading-function doesn't
return an indication that data
could not be read - which may
well involve EOF, e.g. for
getchar, getc, fgetc)
{
process the data;
}
if(feof(my_file )
{
all the data was processed;
}
else
{
there seems to have been an input error - so check ferror()'s result.
}
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Re: What are the differences in EOF & FEOF in the
2005 wrote:
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.t xt", "r"); // Open myfile.txt read-only
while((myChar=f getc(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?
What do *you* think the difference is? Post your answer here, and we
will tell you if you are right or not, and if you are wrong, we will
tell you where your mistake is.
I suggest this for two reasons:
1) It is *much* more effective to learn by doing than by being lectured.
2) It's difficult to see which bit is confusing you. You have already
asked the difference between feof() and EOF, and Richard gave you this
answer. If you just ask the same question again, we don't know how to
make it any clearer.
Re: What are the differences in EOF & FEOF in the
2005 <FW3006@sbcglob al.netwrites:
On Apr 7, 11:47 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
>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"
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.
EOF
[snip]
feof is to
[snip]
So what is the difference when it comes to application?
The comp.lang.c FAQ is at http://www.c-faq.com. Read section 12.
Then read the rest of it.
--
Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Re: What are the differences in EOF & FEOF in the
On Tue, 08 Apr 2008 00:52:07 -0700, Keith Thompson <kst-u@mib.org>
wrote:
2005 <FW3006@sbcglob al.netwrites:
I have K&R - not sure if there had been a "2"
>
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.
>
Which you might be able to finance by selling K&R1 to a collector. <G>
Comment