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

Andrew Koenig ark at alice.att.com
Mon Apr 8 03:25:08 AEST 1991


In article <1991Apr7.064003.8552 at athena.mit.edu> scs at adam.mit.edu writes:

> getchar can return any char value, plus the single, "out of band"
> value EOF [note 1].  Obviously, a variable of type char cannot
> hold any-char-value-or-EOF, so getchar() is specified to return,
> and any variable used to hold its return value must be declared
> as, an int.

Well, almost right.

It returns a non-negative integer or EOF.  If you are on a machine
where chars are naturally signed, getchar will happily return values
that are incapable of comparing equal to any char and are not EOF.
-- 
				--Andrew Koenig
				  ark at europa.att.com



More information about the Comp.lang.c mailing list