home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.msdos.programmer
- Path: sparky!uunet!mnemosyne.cs.du.edu!nyx!glowe
- From: glowe@nyx.cs.du.edu (Glen Lowe)
- Subject: Re: Summary: How to flush keyboard buffer
- Message-ID: <1992Aug14.002006.11461@mnemosyne.cs.du.edu>
- X-Disclaimer: Nyx is a public access Unix system run by the University
- of Denver for the Denver community. The University has neither
- control over nor responsibility for the opinions of users.
- Keywords: Keyboard buffer, DOS
- Sender: usenet@mnemosyne.cs.du.edu (netnews admin account)
- Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
- References: <3748@keele.keele.ac.uk> <1992Aug13.100340.26026@NCoast.ORG>
- Date: Fri, 14 Aug 92 00:20:06 GMT
- Lines: 43
-
- In article <1992Aug13.100340.26026@NCoast.ORG> brown@NCoast.ORG (Stan Bro
- n) writes:
- >In article <3748@keele.keele.ac.uk> coa44@seq1.keele.ac.uk (Mark Scase)
- rites:
- >>
- >>Many thanks to all the people who replied to my recent question I
- >>posted in comp.os.msdos.programmer asking how to flush the keyboard
- >>buffer in Borland C under DOS.
- >>
- >>I received 3 different ways of flushing the keyboard buffer which
- >>worked. They are:
- >>
- >>while (kbhit()) getch();
- >>while (bioskey(1)) bioskey(0);
- >
- >These two are very likely the same thing. If they are implemented in
- >the obvious way, however, they will miss keystrokes like F12.
- >
- >>while (bioskey(1)) if (!getch()) getch();
- >
- >This is a roundabout version of the others. The difference is that if
- >an extended key (function or cursor key) is waiting in the buffer, it
- >will be flushed in one pass through the loop rather than two. But
- >there's no advantage to that feature, and it makes the source program
- >longer.
- >
- >I can understand why keyboard input is so confusing. At a quick count I
- >see eight DOS and BIOS functions to take keystrokes from the buffer or
- >check the buffer for waiting keystrokes, or both. No wonder people get
- >confused!
- >
- >--
- >Stan Brown, Oak Road Systems brown@Ncoast.ORG
- >
- >"Ingrate, n. One who receives a benefit from another, or is otherwise
- >an object of charity." --Ambrose Bierce
-
-
- Try fflush(stdin);
-
- Glen Lowe
- (sorry no fancy sig...)
-
-