Name: Anonymous 2007-11-20 5:57
I'm trying to make a function in C++ that when the button is not held down, there is a blank box in the display, but while the button is held down the box is gone and something else is displayed, in this case the number 1.
This is what I have.
What happens is, when the key is pressed the number one is displayed, but when it is released the one doesn't go away, and the char(219) isn't displayed
cout<<char(219);
int flag=0;
while(!_kbhit()){}
while(_kbhit())
{
if(flag==0)
{
system("cls");
cout<<"1";
flag++;
}
}
system("cls");
cout<<char(219);
This is what I have.
What happens is, when the key is pressed the number one is displayed, but when it is released the one doesn't go away, and the char(219) isn't displayed
cout<<char(219);
int flag=0;
while(!_kbhit()){}
while(_kbhit())
{
if(flag==0)
{
system("cls");
cout<<"1";
flag++;
}
}
system("cls");
cout<<char(219);