getc() != EOF

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Thu May 31 16:14:28 AEST 1984


I beg to differ.  K&R, p. 40:

	``There is one subtle point about the conversion of characters
	to integers.  The language does not specify whether variables
	of type {\tt char} are signed or unsigned quantities.  When a
	{\tt char} is converted to an {\tt int}, can it ever produce a
	{\it negative} integer?  Unfortunately, this varies from
	machine to machine, reflecting differences in architecture.
	One some machines ({\csc pdp-11}, for instance), a {\tt char}
	whose leftmost bit is 1 will be converted to a negative
	integer (``sign extension'').  On others, a {\tt char} is
	promoted to an {\tt int} by adding zeros at the left end, and
	thus is always positive.''

(Now if you state that all {\it civlized} compilers default to signed
characters and allow {\tt unsigned char} datatypes, I will agree.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.unix.wizards mailing list