www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/19/02:49:14

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019