if((c=getchar())!=EOF)

bet at ecsvax.UUCP bet at ecsvax.UUCP
Thu May 31 02:28:04 AEST 1984


As has been said, "if((c=getchar())!=EOF)" is perfectly valid IFF "c" is
declared "int"; NOT if c is a char. Whether char variables are signed or
unsigned, for purposes of comparison or promotion to integer, is explicitly
undefined in C [ref K&R p. 40, p. 183]. This is established and documented.
It is an instance in which the definition of the language is explicitly
ambiguous to allow whatever implementation is more efficient on a particular
machine.
					Bennett Todd
					...{decvax,ihnp4,akgua}!mcnc!ecsvax!bet



More information about the Comp.lang.c mailing list