I am new to C Programming and Ubuntu. I was reading the \"The C Programming Language\" by D.M Ritchie where I found the following code:
#include
Quoting @Veritas's comment,
On linux Ctrl-D only works when the buffer is already empty otherwise it just flushes it. Therefore unless he has pressed enter without any characters after that, he will have to press Ctrl-D twice.
This explains the issue. You have to press it twice because you , after typing Hello
, did not press the Enter to flush the input into the stdin
. So the first time you press CTRL+D, it flushes the data into the stdin
. The second time you press it, EOF
is sent.