basically, in my program, i want to enter ANY number, including 0. if i enter anything other than a number, it will ask to re-enter.
BUT, when i enter 0, it asks me to re-enter, yet 0 should be valid.
is there a way of saying
make sure the entry is a number, and allow 0 to be a value if entered.
is 0 valid for a float?Code:
cout << "\n\nPlease input a, the lower bound: ";
cin >> a;
while (!(a) || cin.get() != '\n' ) // checks for bad input of a
{
cin.clear();
cin.ignore(1000, '\n');
textcolor (12);
cprintf ("\nYou have entered the data incorrectly.\n");
cout << "\nPlease input a, the lower bound: ";
cin >> a;
}