home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16676 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.1 KB  |  37 lines

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