Date: Sat, 17 Jan 2015 12:59:05 -0500 From: less xss <less.xss@gmail.com> To: freebsd-hackers@freebsd.org Subject: ctrl-d appends characters to output Message-ID: <CAGcjGpP0t3%2BcJLRHS5Ggfjao9Vcy0xosAg2KqBWgVA_NtKoNgA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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 $
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGcjGpP0t3%2BcJLRHS5Ggfjao9Vcy0xosAg2KqBWgVA_NtKoNgA>