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?
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?
Comment