Question about feof()
Guy Harris
guy%gorodish at Sun.COM
Sun Dec 21 08:26:50 AEST 1986
> Could someone out there in net-land explain the reason for the
> following behaviour?
>
> If I change the "r" to a "w", then I get a surprise. The call to
> feof() now returns a 0. Why is that?
Because it never read from "/dev/null", and hence didn't know that it was at
the end of the file. What did you *expect* it to do? Unfortunately,
"_filbuf" merely returns EOF if you try to read from something that wasn't
open for reading; it doesn't set the error indication, so "ferror" won't
tell you that you goofed.
More information about the Comp.lang.c
mailing list