I am attempting to allow the user of my program to be able supply an keyboard input while a for loop is looping. The input is going to be used to stop the for loop.
Here is the loop:
Code:
case 1: for (int key = 0; key == 0; key+0)
{
system("CLS");
hunger = hunger + 10;
if (hunger >= 60 && hunger <= 80)
health = health - 10;
else if (hunger >= 80 && hunger <= 180)
health = health -10;
cout << "::Pet's Stats::\n\n\n"
<< "Health: " << health << "\n"
<< "Hunger: " << hunger << "\n\n\n"
<< "Press 1 and enter to get back to the pet care menu!\n\n";
Sleep (5000);
cin >> key;
}
It would also be good if I could allow the user to push any key to exit the loop, but I am unsure how to go about this.
Thanks