getc() != EOF

Gordon Moffett gam at proper.UUCP
Thu Jun 7 12:48:00 AEST 1984


From: bsafw at ncoast.UUCP  Brandon Allbery
Organization: North Coast XENIX, Cleveland


> 	The local "lint" tells me that ((ch = getc ()) != EOF) is illegal on
> IBM-based Cs.  This fits in with the (assumption) that an IBM/370 C would use
> EBCDIC, NOT ASCII, and all 8 bits of the character data are significant, so

No, no, no!  It has nothing to do with EBCDIC; the comparison fails
because EOF is explicitly OUTSIDE of the underlying character set,
WHATEVER IT HAPPENS TO BE.  It is exactly (int)-1, and not (char)-1.

Amdahl's UTS (v7 and Sys V) runs on 370's and uses ascii anyway, but
the chars are unsigned, and that is why any comparison of a character to
-1 (EOF) is always false ... and that is where this discussion
started most recently (and I think its been beaten to death now ...).



More information about the Comp.unix.wizards mailing list