1. c = getchar();
2. printf("%c",c);
On abcde, it prints only 'a' .
1. while((c = getchar()) != EOF){
2. printf("%c",c);
3. }
Input: abcde
While loop...
line 1.. c= a ... line 2... printf output is remembered since its inside...
line 1 c=b .... line2... printf output is remembered since its inside..
........
On enter it will print abcde.
So Why do you think it should only print 'a' ? Printf is executed 5 times you know. So why only 1st printf output will be printed?
Your qsn would look better.. if you have asked why not last one should be printed ..i,e 'e' ...
Variable 'c' is replaced each time... but why printf output will be replaced... Its stored in buffer..It just wants your enter to be printed.