getchar and EOF (was: One more point regarding = and == (more flamage))

Erik Naggum enag at ifi.uio.no
Mon Apr 8 05:50:47 AEST 1991


In article <1991Apr7.064003.8552 at athena.mit.edu>, Steve Summit writes:

>[note 1]  As a return value from getchar, EOF is guaranteed to
>be distinct from all char values.  This is because getchar
>essentially returns (as the ANSI C standard explicitly requires
>it to; see sec. 4.9.7.1) normal characters as unsigned characters
>cast to int (i.e. as positive values, even on a machine on which
>chars are usually signed), while EOF is always a negative value.

>I was going to say that "EOF is guaranteed not to compare equal
>to any char value," but this is not really true.

It is interesting to note that Unicode, one of the proposed new
character sets with "universal" scope and coverage, with its 16-bit
characters has recognized the value of EOF (-1) to applications and
programmers alike, and states

		Not a character code

	FFFF	This 16-bit value is guaranteed not to
		be any Unicode character at all

--
[Erik Naggum]					     <enag at ifi.uio.no>
Naggum Software, Oslo, Norway			   <erik at naggum.uu.no>



More information about the Comp.lang.c mailing list