stdin allows to read with the EOF flag set
问题 On my platform, the following code allows me to successfully read from stdin even if its end-of-file flag is set, which also remains set after the read. To reproduce the behavior, first type the end-of-file shortcut ( Ctrl + D on Unix, Ctrl + Z on Windows) and then type a normal character. #include <stdio.h> // first type the shortcut for EOF, then a single character int main(void) { getchar(); printf("feof(stdin): %s\n", feof(stdin) ? "true" : "false"); int ch = getchar(); if (ch == EOF)