Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!mailrus!tut.cis.ohio-state.edu!osu-cis!dsacg1!dcscg1!cpp90221 From: cpp90221@dcscg1.UUCP (Duane L. Rezac) Newsgroups: comp.lang.c Subject: Re: getch() and getche() in MSC 4.0 Message-ID: <397@dcscg1.UUCP> Date: 21 Oct 88 10:54:33 GMT References: <10508@dartvax.Dartmouth.EDU> Organization: Defense Construction Supply Center, Columbus Lines: 24 From article <10508@dartvax.Dartmouth.EDU>, by yaping@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. | +-----------------------+---------------------------------------------------+