getc() != EOF; -1 byte in file
guido at mcvax.UUCP
guido at mcvax.UUCP
Fri Jun 15 15:38:16 AEST 1984
[This discussion is getting silly. Trying to stamp out one more
misundelstanding...]
Someone suggests that a -1 byte in the file can be promoted to EOF.
No it can't, for the simple reason that getc() is defined as returning
an *int* in the range 0..255. My v7 manual doesn't state this, but just
have a short look at the definition of getc() in /usr/include/stdio.h!
Surely this was intended; the designers of the package were very well
aware of what they were doing: the do warn that the value EOF (-1) returned
by getw() [did you know that it existed?! ever used it?] can be a perfectly
valid integer.
Of course, when assigned to a signed char variable, the values in the range
128..255 become negative; but only then.
--
Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam
guido @ mcvax
More information about the Comp.unix.wizards
mailing list