Hi!
I'm working through K&R slowly and have encountered this example demonstrating getchar and putchar:
I am confused how, each time getchar is called in the loop, it "remembers" which character it's up to in the text stream; how does it not just go straight back to the beginning of the text stream? If somebody could clarify how this works in this case, it would be greatly appreciated.Code:main() { int c; c = getchar(); while (c != EOF) { putchar(c); c = getchar(); } }
Thanks!