|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
paul@dpagin.net wrote:
> > I'm using Linux to program C, however, when I try to do something like (
> > c = getchar() ) != EOF
Do you have 'c' defined as a char, or as an int? getchar() returns an
int rather than a char, using the high bits to indicate error conditions
such as EOF, and the lower bits to hold the value of valid data returned.
gr@eclipsed.net wrote:
> Have you tried using '^V^D' there instead of literally typing out
> EOF? (That's control-V control-D. ^V makes the subsequent control
> character visible.)
In this context, EOF is a conditioned returned by read(), not a character.
(It's perfectly valid to read ASCII character 4, ^D, from a file).
> EOF is #defined in a system include somewhere which you're probably
> not including in your source. Figuring out which include file would
EOF is defined in stdio.h, along with getchar() and friends. (If it
wasn't defined, cc wouldn't be compiling the code in the first place)
-mct
|
|