I am writing a program that copies input to output character by character on Linux terminal. The code is as follows (from Dennis Ritchie's C book)
#include <stdio.h>
/* copy input to output; 2nd version*/
main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
}
The program and its execution works fine. But I want a slight modification.
The output appears on terminal for each new line character (when I press enter). I want to delay the output till I signal the end of file by pressing Ctrl + D. What modifications I have to do for the program in-order to delay my output on terminal.
Sample output I am getting is as follows:
abcd (enter)
abcd
llefn;elnf(enter)
llefn;elnf
(ctrl+d)
Sample output I wants to get is as follows:
abcd(enter)
llefn;elnf(ctrl+d)
abcd
llefn;elnf