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

John F Carr jfc at athena.mit.edu
Tue Apr 9 08:28:24 AEST 1991


In article <3043 at cirrusl.UUCP>
	dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:

>I have always assumed that EOF is guaranteed to be -1.  I think there
>is enough history behind EOF == -1 (just as with NULL == 0) that it
>isn't likely to be anything else.

The ANSI standard says EOF is a negative number.  It does not have to be -1.
If I ever write a C implementation which doesn't need to be binary
compatible with an existing UNIX library, I'll make EOF something like -256
to make sure it can never equal a signed or unsigned char value.
Traditionally, EOF is -1.  I don't know what POSIX says.

--
    John Carr (jfc at athena.mit.edu)



More information about the Comp.lang.c mailing list