#include <stdio.h>
#include <stdlib.h>
int main()
{
int c;
c = getchar();
while (c != EOF) {
putchar(c);
}
return 0;
}
when I compile and give input ABC and then press enter, the never ending loop starts like AAAAAAAAA....
And now look at this code below
#include <stdio.h>
#include <stdlib.h>
int main()
{
int c;
c = getchar();
while (c != EOF) {
putchar(c);
c = getchar (); // added this single line
}
return 0;
}
In this program, when I input ABC, the output is ABC. Can anyone please explain why it is not showing just a single A as output?