home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8528 < prev    next >
Encoding:
Text File  |  1992-08-13  |  2.1 KB  |  59 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!mnemosyne.cs.du.edu!nyx!glowe
  3. From: glowe@nyx.cs.du.edu (Glen Lowe)
  4. Subject: Re: Summary: How to flush keyboard buffer
  5. Message-ID: <1992Aug14.002006.11461@mnemosyne.cs.du.edu>
  6. X-Disclaimer: Nyx is a public access Unix system run by the University
  7.     of Denver for the Denver community.  The University has neither
  8.     control over nor responsibility for the opinions of users.
  9. Keywords: Keyboard buffer, DOS
  10. Sender: usenet@mnemosyne.cs.du.edu (netnews admin account)
  11. Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
  12. References: <3748@keele.keele.ac.uk> <1992Aug13.100340.26026@NCoast.ORG>
  13. Date: Fri, 14 Aug 92 00:20:06 GMT
  14. Lines: 43
  15.  
  16. In article <1992Aug13.100340.26026@NCoast.ORG> brown@NCoast.ORG (Stan Bro
  17. n) writes:
  18. >In article <3748@keele.keele.ac.uk> coa44@seq1.keele.ac.uk (Mark Scase) 
  19. rites:
  20. >>
  21. >>Many thanks to all the people who replied to my recent question I
  22. >>posted in comp.os.msdos.programmer asking how to flush the keyboard
  23. >>buffer in Borland C under DOS.
  24. >>
  25. >>I received 3 different ways of flushing the keyboard buffer which
  26. >>worked.  They are:
  27. >>
  28. >>while (kbhit()) getch();
  29. >>while (bioskey(1)) bioskey(0);
  30. >
  31. >These two are very likely the same thing.  If they are implemented in
  32. >the obvious way, however, they will miss keystrokes like F12.
  33. >
  34. >>while (bioskey(1)) if (!getch()) getch();
  35. >
  36. >This is a roundabout version of the others.  The difference is that if
  37. >an extended key (function or cursor key) is waiting in the buffer, it
  38. >will be flushed in one pass through the loop rather than two.  But
  39. >there's no advantage to that feature, and it makes the source program
  40. >longer.
  41. >
  42. >I can understand why keyboard input is so confusing.  At a quick count I
  43. >see eight DOS and BIOS functions to take keystrokes from the buffer or
  44. >check the buffer for waiting keystrokes, or both.  No wonder people get
  45. >confused!
  46. >
  47. >-- 
  48. >Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  49. >
  50. >"Ingrate, n.  One who receives a benefit from another, or is otherwise
  51. >an object of charity."                          --Ambrose Bierce
  52.  
  53.  
  54. Try fflush(stdin);
  55.  
  56. Glen Lowe
  57. (sorry no fancy sig...)
  58.  
  59.