Why doesn’t getchar() recognise return as EOF on the console?

Pressing enter doesn’t actually cause an EOF (“end of file”). You have to signal that you are completely finished with providing input; on Unix you typically do that by pressing CtrlD. On Windows I believe it’s CtrlZ followed by enter, but I’m really not sure about that.

Leave a Comment