Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!ucbvax!tut.cis.ohio-state.edu!osu-cis!att!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: learning c Keywords: getchar() Message-ID: <9148@alice.UUCP> Date: 4 Apr 89 03:34:18 GMT References: <1091@bnlux0.bnl.gov> <584@greens.UUCP> Distribution: usa Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 19 In article <584@greens.UUCP>, matthew@sunpix.UUCP ( Sun NCAA) writes: > I know your problem well. What you are looking for is a 'getch()' or > 'getche()' function in place of the 'getchar()' function. Barring that try > c = getchar(); > fflush(stdin); Why depend so intimately on the detailed behavior of the C run-time library? Not all implementations support fflush(stdin). The following is much more portable: c = getchar(); if (c != '\n') while (getchar() != '\n') ; -- --Andrew Koenig ark@europa.att.com