I compile my code then run: $ ./a.exe < input.txt For some reason it doesn't read the first character (t is missing from test in first line) and there is also a weird character at the end. How do I combat these two errors? Thanks
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char c = getchar();
while (c != EOF){
printf("%c ",c);
c = getchar();
}
return (0);
}
Sample execution:
$ ./a.exe < input.txt
e s t l i n e o n e
t e s t l i n e t w o
f i n a l l i n e ▒