EOF

Zack Weinberg zack@wolery.cumb.org
Fri Apr 7 14:43:00 GMT 2000


On Fri, Apr 07, 2000 at 01:50:12PM -0700, Donald Holloway wrote:
> Dear Guru,
> 
> The following statement isn't working with GNU C:
> 
> while ((c = getchar()) != EOF)
>           .
>           .
>           .
> 
> It appears the compiler doesn't recongize the EOF 
> as a key work.  What is the substitute "end of
> file" word or variable that I can use instead of EOF?

You don't provide a complete example so it is not possible to be
certain what your problem is.  However, the odds are that you have
forgotten to include <stdio.h>.  EOF is not a keyword, but a macro
defined in that header.

Also, make sure 'c' is declared as an int, not a char.

zw


More information about the Gcc-bugs mailing list