4 ms·
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 gc
by sstanie 8y 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/spolsky%7Csort:date/comp.lang.c/BKhAacGNtZI/GLSW-QG_O3MJ 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?
- brianpgordon 8y agoIt looks like for some reason GCC is returning EOF from the second getchar() call and his terminal is rendering it as ^@.