From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: fread/fwite return value Date: Fri, 18 Jul 1997 09:01:51 -0400 Organization: Cornell University Lines: 26 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <33CF693F.32B3@cornell.edu> References: <97Jul17.140456gmt+0100 DOT 16641 AT internet01 DOT amc DOT de> Reply-To: asu1 AT cornell DOT edu NNTP-Posting-Host: 128 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Chris Croughton wrote: > > A. Sinan Unur wrote: > > > while( fread(&c, 1, 1, f) ) > > printf("%c", c); > > (I fail to see, however, why using fread is any better > than using getc; it's a lot less efficient for a single > character in most implementations...) oh, really? this was just part of a simple example to show that checking the return value of fread against (size_t) -1 is a stupid notion. the issue was whether the original poster should suppress the warning or assume that the libc documentation was wrong. as others (including eric francis) and i have pointed out, in this case it is the documentation that is wrong. i think the most practical way of checking the return value of a call to fread (i saw it in plauger's "standard c library") is given in my correction post. given that i try to avoid reading/wiriting structures wholesale, the whole issue is kinda beside the point for me anyway. let's end this thread. -- Sinan