Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>kbhit() check keyboard input buffer for character waiting</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 kbhit()                 Check Keyboard Input Buffer for Character Waiting

 #include   <conio.h>

 int        kbhit(void);

    kbhit() checks the console for a recent keypress.  If there has been
    one, the character is waiting in the input buffer and can be read
    with getch() or getche().

       Returns:     Nonzero if a key has been pressed; 0, if not.

         Notes:     If getch() or getche() is called to read a key, but
                    kbhit() is not called first to check whether a
                    character is waiting in the buffer, the program may
                    pause until a key is pressed.

   -------------------------------- Example ---------------------------------

    The following statements check whether a key has been pressed before
    they read a character from the console.

           #include <conio.h>

           int keypress, ch;

           main()
           {
               keypress = kbhit();
               if (keypress != 0)
                  ch = getche();
           }


See Also: getch() getche()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson