Hacker News new | ask | show | jobs
by sstanie 2985 days ago
For anyone that clicked through to his 1988 question on comp.lang.c ... what was causing what he was happening? I'm assuming something with an old version of gcc, but I can't reprocue it- I get the correct result using both cc and gcc.

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?

1 comments

It looks like for some reason GCC is returning EOF from the second getchar() call and his terminal is rendering it as ^@.