It\'s my first time posting here, so hopefully this goes as intended.
I\'m doing one of the early exercises from K&R. The objective is to use getchar() to get a
When you type stuff and you hit enter, everything is stored in an internal buffer. So every time the loop executes, it hits getchar
who *does * go to that buffer and pulls a single character.
But what I don't understand is why execution doesn't stop with each subsequent iteration of the loop
The program stops only in the event where getchar
doesn't find anything in that buffer.
Now \n
has nothing special in this case. It's just the convention that the CLI doesn't actually "send" what you type to the program until you hit return (i.e. you can hit backspace and so on).