Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!bbn.com!pren From: pren@bbn.com (Peifong Ren) Newsgroups: comp.unix.admin Subject: fflush doesn't work on SunOS 4.1 ? Message-ID: <64245@bbn.BBN.COM> Date: 17 May 91 14:22:34 GMT Sender: news@bbn.com Reply-To: pren@BBN.COM (Peifong Ren) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 33 Can someone help me with this problem? In going from Sun OS 3.5 to 4.1, it seems that fflush(stdin) no longer clears the keyboard input buffer. Is this true, and how should I clear keyboard input under 4.1? In the example program below, when compiled under 4.1, the from the user's first typein remains in the buffer after the scanf and fflush, so it is seen by the getc, and the the user never has a chance to supply the second typein. Please send reply to pren@bbn.com! Thanks! ================= #include int i; main() { printf("type a number and : "); fflush(stdout); scanf("%d", &i); fflush(stdin); /* flush any arg terminator char */ printf(" type a single char and : "); fflush(stdout); i = getc(stdin); printf(" char=%d\n", i); fflush(stdout); } ===================