getc() != EOF - (nf)

paul at ism780.UUCP paul at ism780.UUCP
Wed Jun 6 14:09:17 AEST 1984


#R:rlgvax:-194900:ism780:14400009:000:632
ism780!paul    Jun  4 17:21:00 1984

[Nothing happens till it happens twice.]

All the comments I have seen here on

#define EOF (-1)
      char c;
      while ( (c = getc()) != EOF )

ignore one possibility:
if chars are signed and the file being read contains a byte equal to -1,
the loop will terminate BEFORE the end-of-file is reached!  If, that is,
the compiler implements assignment expressions correctly.  The VAX System III
compiler, for one, gets it wrong.

Paul Perkins
...{uscvax|ucla-vax|vortex}!ism780!paul
...decvax!yale-co!ima!ism780!paul
"Any opinions expressed in this message are not necessarily those of any
real person, organization, or computer."



More information about the Comp.unix.wizards mailing list