Originally Posted by
whiteflags
So if you send EOF immediately after some data, it is likely that fread will return "a short object count" instead of zero like you expected, which ultimately determines gets return value. It is no different from what happens when reading a file. You may encounter EOF while you read the last line, but only the call after that fails for certain. This is so the last of the data has an opportunity to be processed.
And remember that when you send EOF from the console there is actually two pieces of data to read: the EOF, and a newline. If the newline weren't there, input would fail like you expect