#include <stdio.h>
/* copy input to output */
main()
{
int c;
c = getchar();
while(c != EOF)
{
putchar(c);
c = getchar();
}
return 0;
}
In the given code, the program displays the input character. It reads every character one by one (into the variable 'c') and outputs the same read characters simultaneously. The program terminates when the EOF character is given as input.
When I ran the code in my IDE (Code::Blocks 16.01) and input a string, eg: Hi! My name is C.\n
The output is displayed after '\n' and not simultaneously. Isn't the output supposed to be as - "HHii!! MMyy nnaammee iiss CC.."?
Bold letters indicate the output.