Determining EOF expression
问题 I need to verify that the expression getchar() ! = EOF is 0 or 1 . My current code: #include <stdio.h> int main (int argc, char *argv[]) { int c; while (( c= getchar()) != EOF) { printf("%d ", c != EOF); putchar(c); } printf("\n%d\n", c != EOF); } When I try to run that I get 98980980 1 91 81 91 81 01 91 81 01 I`m not sure if I got this right. EDIT: Ok the question was actually " How to generate EOF " and the solution was to press ctrl+D. 回答1: I'm not very sure if you want this answer, but as