getch() and getche() in MSC 4.0

Duane L. Rezac cpp90221 at dcscg1.UUCP
Fri Oct 21 20:54:33 AEST 1988


>From article <10508 at dartvax.Dartmouth.EDU>, by yaping at eleazar.dartmouth.edu (Yaping Xu):
> Has anyone else had trouble with getch() and getche() in Microsoft C v. 4.0?
> They often skip every other keypress on me--and in one case, they skip two
> keypresses out of three!  Maybe it's my code.  This occurs mainly when I try
> 
> 	c = toupper(getch());
 
> 				--Scott
I'm not sure about Microsoft C, but with turbo C and C86 optimizing Compiler, 
the getch() and getche() read one character out of the buffer. I have run into
the problem with these functions skipping inputs due to some information that 
was left in the buffer from a previous read. When the second calling of the 
function occurs, it reads the remaining data in the buffer, appearing to run 
right past the requested input. At times I have had to add an extra getche() or
getch() in front of the one that is skipping the input in order to clear the 
buffer. 

(by the way, if anyone has a good method to insure that the keyboard buffer is 
 empty, Please post it.)

-- 
+-----------------------+---------------------------------------------------+
| Duane L. Rezac        |These views are my own, and NOT representitive of  |
| dsacg1!dcscg1!cpp90221|my place of Employment.                            |
+-----------------------+---------------------------------------------------+



More information about the Comp.lang.c mailing list