I wrote a simple echo program, which reads standard input character-by-character and then prints it to standard output character-by-character.
#include <stdio.h>
int main() {
int c;
while ((c = getchar()) != EOF) {
putchar(c);
}
return 0;
}
I was expecting it to break out of the while loop and terminate when I key-in Ctrl-Z, but the program keeps running.
Sample run:
(Input) all yuor base are belong to usCtrl-Z
(Output) all yuor base are belong to us
continue waiting for input...
One (strange) thing I noticed is the program will terminate only when Ctrl-Z is entered all by itself.
(Input) oh naise
(Output) oh naise
(Input) Ctrl-Z
programing terminates...
Why does this happen? Why does the program not terminate when Ctrl-Z is with other characters? WHY IS THE WORLD COMING TO AN END?!
Anyway, I am using Command Prompt (if that matters), and thanks in advance for any help.