Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Testing the key...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 26043 of 26967
Post > Topic >>

Testing the keyboard buffer for MT/Not MT

by NaN <no@[EMAIL PROTECTED] > May 2, 2008 at 10:25 PM

I've been trying to use _kbhit() but it didn't do what I thought it 
would from books, "Detects whether a keypress is available for reading."

Herbert Schildt says,
"If the user has pressed a key, this function returns
true(non-0), but does not read the character.
If no keystroke is pending, kbhit() returns false (0)."

Here is the test code,

#include<conio.h>
void main(void) {
         int ig1=0, ig2=0, ik=-1;
         ig1 = _getch();
         ik = _kbhit();
         ig2 = _getch();
         _getch();
         printf("ig1=%d, ik=%d, ig2=%d", ig1,ik,ig2);
         return;
}

Whatever keys I press a runtime, ik returned as 0. Where else would a 
keystroke be "waiting" except in the buffer?  If _kbhit() does not look 
at the buffer, what does it look at?
 




 4 Posts in Topic:
Testing the keyboard buffer for MT/Not MT
NaN <no@[EMAIL PROTECT  2008-05-02 22:25:02 
Re: Testing the keyboard buffer for MT/Not MT
roberson@[EMAIL PROTECTED  2008-05-02 21:40:07 
Re: Testing the keyboard buffer for MT/Not MT
CBFalconer <cbfalconer  2008-05-02 18:19:10 
Re: Testing the keyboard buffer for MT/Not MT
user923005 <dcorbit@[E  2008-05-02 21:30:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 6:42:50 CDT 2008.