News for hackers. Stuff that matters.
Re:Strange and maddening rules by sstanie on Tuesday April 24, 2018 @10:46AM (#16912991)
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?

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 ^@.