Well, your code has no loop, so you'll always fall though to the "end."
Perhaps you meant
$ cat temp.c
while ((c=getchar()) != EOF)
$ echo -n abcd | ./temp
Note: ^C will terminate the execution of the whole program, not end the input. ^D is what you want.
Note2: The getchar function will read the '\n' at the end of each input line, hence the -n
option to the echo
command in the sample output, above.