home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!mcsun!sunic!ugle.unit.no!alf.uib.no!krill!yngvar
- From: yngvar@krill.NoSubdomain.NoDomain (Yngvar Foelling)
- Subject: Re: strange things with gcc
- Message-ID: <1992Nov17.165355.13147@alf.uib.no>
- Sender: yngvar@krill (Yngvar Foelling)
- Organization: University of Bergen, Norway
- References: <9232201.24197@mulga.cs.mu.OZ.AU> <15984@goanna.cs.rmit.oz.au>
- Date: Tue, 17 Nov 92 16:53:55 GMT
- Lines: 25
-
- I've seen plenty of questions like this:
- - How can I dump the input buffer?
- - Use fflush(stdin).
- - No. Not standard.
- - How, then?
- - Dunno.
- - Can't be done.
-
- Or the like. What I don't understand is why nobody have used what to me seems
- like the most reasonable solution. It seems like most of the time the intention
- is to discard the remainder of the line after having read some input, or simply
- to wait for the user to press RETURN.
-
- So what's wrong with this?
-
- int c;
-
- do {
- c = getchar();
- } while (c != '\n' && c != EOF);
-
- --
- ISO 8859-1: Yngvar F°lling | Private address:
- ASCII: Yngvar Foelling | Tertnesveien 121
- E-mail: yngvar@imr.no | N-5084 Tertnes
-