Author: Unknown
Subject: Get rid of extra char at EOF of input redirection?
Date: Friday, 06 Nov 2020, 03:31:25
In my program test.c I have:
char c;
while ((c = getchar()) != EOF) {
printf("%d\n", c);
}
I am running
./test < input.in
With 'abc' on one line in input.in. However, I get the output:
97
98
99
10
How do I get rid of the last 10? Even if the file is completely empty, the program will still print one 10.
PREV
INDEX
NEXT