0

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();
}
2
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by esy928
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.