Mail Archives: djgpp/1997/07/17/08:12:09
A. Sinan Unur wrote:
> while( fread(&c, 1, 1, f) )
> printf("%c", c);
While this is correct according to ANSI C, I prefer
to do:
while( fread(&c, 1, 1, f) > 0 )
printf("%c", c);
just in case it returns a negative value (some Unix
systems have done that to me in the past). Defensive
programming. OK, paranoid programming <g>...
(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...)
Chris C
- Raw text -