Tests whether a keystroke is currently available
#include <nwconio.h> int kbhit (void);
kbhit returns TRUE or FALSE, depending on availability of keystrokes. When a keystroke is available, TRUE is returned. If an error is detected or if no keystrokes are available, FALSE (0) is returned. When an error occurs, errno is set.
When a keystroke is available, you can call getch or getche to obtain the keystroke. With a stand-alone program, you can call kbhit continuously until a keystroke is available.
#include <stdlib.h> #include <nwconio.h> #include <stdio.h> main () { while(!kbhit()); printf ("the character is "); getche (); getch (); }