I've got a cin
which is looking for a double value, but if a string value of any length is passed, my while loop gets stuck in an infinite output loop.
Here's what I've got:
double milesPerYear = 0;
cin >> milesPerYear;
while (milesPerYear <= 0) {
cout << "Please input a positive number above 0" << endl;
cin >> milesPerYear;
}
If the user were to input anything which has a letter in it, it will indefinitely output Please input a positive number above 0.
I want it to prompt the user to input a new value.
Thanks! Nathan