I just started studying C and have no idea how computer works. So it could be dumb question.
When I saw this code,
Code:
#include <stdio.h>
main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
The way it works I assume is that when I type a character, it would print same character instantly before I type next character. For instance, if I type "apple", I thought it would run like this.
a a p p p p l l e e
but rather it just printed same character string I typed til enter. So I googled, and found something called "buffer". What I figured out myself is that when I type something, it is not read by program until I press enter, and when I press enter, the character string in buffer is read by program. Then program prints. Is this how buffer and program works?