I am trying to learn how input/output works, and was curious about something regarding this basic code from a textbook:
#include <stdio.h>
/* copy input to output; 1st version */
int main()
{
int c;
c = getchar();
while (c != EOF) {
putchar(c);
c = getchar();
}
}
After I use gcc to turn this code into an executable, it runs completely fine. However, within the executable, whenever I press "enter", all my input is sent out, and thus also printed on the next line as output. How could I set things up so that so I can get the new line, '\n', that I want out of enter, without signalling that I want to send my input? I am currently working in the Linux MATE terminal, if that is an influencing factor.