I am running the following program from the C Programming Language book:
#include
main()
{
int c;
while((c=getchar()) != EOF)
putchar
When you type ^D ('end-of-transmission') the input buffer is flushed and everything you typed until now is sent to your program (without actually sending ^D character). It is similar to typing newline character, however, in this case the newline character itself is sent too. A program considers its input as closed when it reads zero characters. This happens when you type newline followed by ^D or two consecutive ^D.