Mail Archives: djgpp/1997/07/19/02:49:14
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 -