Re:Strange and maddening rules
by brianpgordon on Tuesday April 24, 2018 @03:45PM
(#16915916)
It looks like for some reason GCC is returning EOF from the second getchar() call and his terminal is rendering it as ^@.
https://groups.google.com/forum/#!searchin/comp.lang.c/spols...
Are you allowed to use getchar() twice? (seems like a silly question? read on!)
---------------------------------------------------- kangaroo% cat test.c #include <stdio.h>
main() { int c; c=getchar(); putchar(c); c=getchar(); putchar(c); putchar('\n'); } kangaroo% gcc test.c kangaroo% echo "Hi" | a.out H^@ kangaroo% cc test.c kangaroo% echo "Hi" | a.out Hi ---------------------------------- Anybody know what's going on?