I\'m reading the book \"The C Programming Language\" and there is an exercise that asked to verify that the expression getchar() != EOF is returning 1 or 0. Now
EOF can be triggered through keyboard by pressing keys ctrl+d in Unix and ctrl+c in Windows.
Sample Code:
void main()
{
printf(" value of getchar() != eof is %d ",(getchar() != EOF));
printf("value of eof %d", EOF);
}
Output:
[root@aricent prac]# ./a.out
a
value of getchar() != eof is 1 value of eof -1
[root@aricent prac]# ./a.out
Press ctrl+d
value of getchar() != eof is 0 value of eof -1[root@aricent prac]#