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

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!montebello.ecom.unimelb.EDU.AU!carl
  3. From: carl@montebello.ecom.unimelb.EDU.AU (Carl Brewer)
  4. Subject: Funny problem with a pause routine
  5. Message-ID: <9232123.22703@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. Date: Mon, 16 Nov 1992 12:17:15 GMT
  9. Lines: 38
  10.  
  11. ok, here's a routine I copied from a book, and can see no reason why
  12. it won't work, but first, some background ..
  13.  
  14. compiler, gcc on SunOS 4.1.2, (ANSI)
  15.  
  16. the bug
  17.  
  18. it works the first time I call it, but from then it only works if
  19. I get it to do the getchar() twice ...
  20.  
  21. otherwise, it just skips over it, and there is no wait for the <cr>
  22.  
  23.  
  24.  
  25. enough preamble
  26.  
  27. void pause()
  28. {
  29.     char ans;
  30.     fflush(stdin);
  31.     fprintf(stdout, "Press <Return> to continue\n");
  32.     ans = getchar();
  33.     fflush(stdin);
  34.  
  35.     return;
  36. }
  37.  
  38. I've tried this with the getchar cast to void [ (void)getchar(); ],
  39. and tried gets(), getc() etc, all to no avail.
  40.  
  41. any ideas?
  42.  
  43.  
  44. -- 
  45.  Annal  Natrach, Usthvah Spethed,         carl@ecr.mu.oz.au (IRC: Bleve)
  46.  Dochoel Dienve                           carl@munagin.ee.mu.oz.au
  47.                       carl@montebello.ecom.unimelb.EDU.AU
  48.  Merlin, where are you?  Call your dragon, to weave a mist...
  49.