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

Erik Naggum enag at ifi.uio.no
Fri Apr 12 10:58:01 AEST 1991


In article <1991Apr8.222824.24474 at athena.mit.edu>, John F Carr writes:
   In article <3043 at cirrusl.UUCP>, 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.

POSIX.1 points to the C standard and has no further comments on EOF.

--
[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