int readUntilValidBaseRead( int &base )
{
base = 0;
while ( base > 9 || base < 2)
{
cout << "Enter Base: " << endl;
cin >> base;
if (base > 1 && base < 10)
{
return base;
}
else
{
cout << "a valid base number is in the range of 2 to 9 inclusively" << endl;
base = 0;
}
}
}
For an assignment I'm doing, I need to use a function to get a base, and this is what I wrote. If any number is input, the code works fine. If I input f, then the code gets stuck repeating
a valid base number is in the range of 2 to 9 inclusively
Enter Base: