Detecting EOF in C
EOF is just a macro with a value (usually -1). You have to test something against EOF, such as the result of a getchar() call. One way to test for the end of a stream is with the feof function. if (feof(stdin)) Note, that the ‘end of stream’ state will only be set after a … Read more