05-15-2007
80,
0
Join Date: Dec 2006
Last Activity: 30 September 2007, 3:54 PM EDT
Posts: 80
Thanks Given: 0
Thanked 0 Times in 0 Posts
between below program that spits out 0 for EOF and /usr/include/stdio.h, which has , I am bit confused. I ran below program and I do get 0 for EOF..
can someone please help bit further..
/* End of file character.
Some things throughout the library rely on this being -1. */
#ifndef EOF
# define EOF (-1)
#endif
/* This program prompts for input, and then captures a character
* from the keyboard. If EOF is signalled (typically through a
* control-D or control-Z character, though not necessarily),
* the program prints 0. Otherwise, it prints 1.
*
* If your input stream is buffered (and it probably is), then
* you will need to press the ENTER key before the program will
* respond.
*/
#include <stdio.h>
int main(void)
{
printf("Press a key. ENTER would be nice :-)\n\n");
printf("The expression getchar() != EOF evaluates to %d\n", getchar() != EOF);
return 0;
}