ctrl-d appends characters to output
less xss
less.xss at gmail.com
Sat Jan 17 17:59:07 UTC 2015
I've searched around quite a bit with no luck on this matter. I currently
have an issue where I send EOF (ctrl-d) to some simple K&R2 exercises and
the terminal returns the D character appended to my data when EOF is sent.
I wish to prevent any and all extra characters from being appended and I
would also like to understand why it's happening. The following code
is an example exercise from K&R2 that yield said problem.
#include <stdio.h>
int main() {
double nc;
for (nc = 0; getchar() != EOF; ++nc) {
; /* syntactic null statement */
}
printf("%.0f\n", nc);
}
$ ./a.out
0D
$
More information about the freebsd-hackers
mailing list