Mail Archives: djgpp/1997/09/08/11:22:56
On Mon, 08 Sep 1997 02:06:48 -0700, Chris Thompson
<cdthompson AT juno DOT com> wrote:
>Jay Slanker wrote:
>>
>>
>> if(kbhit())
>> control=getch();
>>
>This is your problem. Once kbhit() returns true, it'll keep returning
>true. I'm not sure exactly what resets is, but your best bet is to use
>the _bios_keybrd() routines to check for a character ready and to read
>it. Most compilers I've seen have these functions.
>
>Chris Thompson
>cdthompson AT juno DOT com
I have not found this to be a problem; in both DJGPP and TC++, getch()
seems to remove one character from the keyboard buffer and thereby
turns off kbhit(). There may well be trouble if one /holds down/ a
key, which is why I usually put a loop like this
while (kbhit()) getch();
in critical locations, but a single keypress should be fine. I
suspect the trouble stems from some other part of the code.
Nathan Thompson
---------------
Remove 'no.spam.' to reply.
- Raw text -