This is a piece of my program, the Dragon() function at the bottom is defined and works as it should in my larger program. I was trying to kick back out invalid inputs and have the user enter a valid one with the while loop. It works as intended for any integer inputs, but if I enter, for example, the letter k, the program starts looping my dragon function indefinitely. Any hints to a direction I should go would be helpful, thank you.
int main()
{
srand(static_cast<unsignedint>(time(0)));
int howMany;
cout << "How many times do you want the dragon to attack? \nEnter a number between 1-10: ";
cin >> howMany;
while (howMany < 1 || howMany > 10)
{
cout << "Invalid input. \nEnter a number between 1-10: ";
cin >> howMany;
}
for (int i = 0; i < howMany; i++)
{
cout << i + 1 << ". ";
Dragon();
}
return 0;
}