Path: utzoo!attcan!uunet!yale!spolsky
From: spolsky@yale.EDU (Joel Spolsky)
Newsgroups: comp.lang.c
Subject: multiple getchar()'s in gcc (weird)
Keywords: gcc, GNU, getchar, tiddlywinks
Message-ID: <38635@yale-celray.yale.UUCP>
Date: 23 Sep 88 14:20:38 GMT
Sender: root@yale.UUCP
Reply-To: spolsky@yale.edu (Joel Spolsky)
Organization: Yale University Computer Science Dept, New Haven CT  06520-2158
Lines: 27

Are you allowed to use getchar() twice? (seems like a silly question?
read on!)

----------------------------------------------------
kangaroo% cat test.c
#include 

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?

Joel Spolsky             bitnet: spolsky@yalecs     uucp: ...!yale!spolsky
Yale University          arpa:   spolsky@yale.edu   voicenet: 203-436-1483
"You can't expect to wield supreme executive power just 'cause 
some watery tart threw a sword at you!!"