Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!lll-lcc!styx!ames!oliveb!sun!gorodish!guy
From: guy%gorodish@Sun.COM (Guy Harris)
Newsgroups: comp.lang.c
Subject: Re: Question about feof()
Message-ID: <10715@sun.uucp>
Date: Sat, 20-Dec-86 17:26:50 EST
Article-I.D.: sun.10715
Posted: Sat Dec 20 17:26:50 1986
Date-Received: Sat, 20-Dec-86 23:43:25 EST
References: <31800001@garrity>
Sender: news@sun.uucp
Lines: 11
Summary: What did you EXPECT it to do?

>    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.