#include <conio.h>
int main(){
while (!_kbhit())
cout << "Hit me!" << endl;;
cout << " You Hit " << static_cast<char>(_getch()) << endl;
}
Prototype: int kbhit(void);
Header File: conio.h
Explanation: This function is not defined as part of the ANSI C/C++ standard. It is generally used by Borland's family of compilers. It returns a non-zero integer if a key is in the keyboard buffer. It will not wait for a key to be pressed.
MSND
_kbhit returns a nonzero value if a key has been pressed. Otherwise, it returns 0
The _kbhit function checks the console for a recent keystroke. If the function returns a nonzero value, a keystroke is waiting in the buffer. The program can then call _getch or _getche to get the keystroke.