# Turbo C help (about kbhit command)



## esy928 (May 3, 2007)

Im creating a slot machine program and used the kbhit command to stop the reels. Right now im tryn to change how the program works instead of stoping it all at once i want the reels to stop one at a time (everytime a key is pressed one reel would stop)
the problem is i dont know to reset the kbhit command. once you pressed anything on the keyboard itll register that you have pressed somethin and will not reset it anymore.
please help im new to C...
thanks in advance

here's the current code:
itll stop the first number but during the next iteration itll automatically stop the second num then the third

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
main()
{
int x1,x2,x3,y=0;
randomize();
for(;
{
clrscr();
if(y==0)
x1=rand()%9;
if(y<=1)
x2=rand()%9;
if(y<=2)
x3=rand()%9;
printf("%d %d %d",x1,x2,x3);
if(kbhit())
y++;
}
getche();
}


----------



## lotuseclat79 (Sep 12, 2003)

See if you can find the appropriate help for your problem here.

-- Tom


----------



## johnhe (May 11, 2007)

To reset kbhit() after it sees a keystroke you need to remove the waiting keystroke using something like _getch().


```
if ( kbhit() ) {
  y++
  _getch();
}
```


----------

