the following excerpt is taken from "The C Programming Language" by K & R:
The code doesn't work as described, though. The entered characters are printed only after I press Enter or enter the EOF signal. They are not printed one by one as the authors suggest.
while ((c = getchar()) != EOF)
The while gets a character, assigns it to c, and then tests whether the character was the end- of-file signal. If it was not, the body of the while is executed, printing the character. The while then repeats. When the end of the input is finally reached, the while terminates and so does main.
This is very strange programatically and very difficult for me to grasp. Eg. I enter ten characters and press Enter and only then is the body of the loop executed ten times... Strange... Any comments that might make this a bit clearer for me?