User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed



Syntax of kbhit

#include "graphics.h"
int kbhit(void);

Description of kbhit

The kbhit function is available in the winbgim implementation of BGI
graphics. You do not need to include conio.h; just include graphics.h.
The function returns true (non-zero) if there is a character in the input
buffer ready to read. Otherwise it returns false. In order to work, the
user must click in the graphics window (i.e., the Windows focus must be
in the graphics window).

Example of kbhit

#include "graphics.h"
#include <stdio.h>// Provides sprintf
void outintxy(int x, int y, int value);
int main( )
    int i;
    // Initialize the graphics window.
    initwindow(400, 300);
    // Convert some numbers to strings and draw them in graphics window:
    outtextxy(20, 130, "Click in this graphics window,");
    outtextxy(20, 140, "and then press a key to stop.");
    outtextxy(10, 10, "Here are some numbers:");
    for (i = 0; !kbhit( ); i++)
  outintxy(20 + (i/10)*40 , (i % 10)*+10, i);
    closegraph( );
void outintxy(int x, int y, int value)
   char digit_string[20];
   sprintf(digit_string, "%d", value);
   outtextxy(x, y, digit_string);

See also

output of kbhit example

  no output of example at the moment
  do not hesitate and add it...  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/graphics.h/kbhit.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz