我编写了以下程序来了解 EOF 的行为:
#include<stdio.h>
int main ()
char c = 0;
printf("Enter some chars, EOF stops printing:");
while ((c == getc(stdin)) != EOF)
printf("c = %c, (int) c = %d\n", c, (int) c);
return 0;
}
但是,如果我输入一些东西,例如abcd
我得到这个输出:
c = a, (int) c = 97
c = a, (int) c = 97
c = a, (int) c = 97