trying to get a function to work however I'm still pretty beginner at coding - this function is clearing all my inputs as valid however, as I understand it, it should be failing them?
char input;
bool valid;
do
{
valid = false;
gotoXY(col, row);
cin >> input;
if (cin.fail())
{
message("Invalid input! Please re-enter.", 5, offset);
cin.clear();
clearLine(col, row);
clearLine(0, row + 2);
}
else
{
valid = true;
}
cin.ignore(150, '\n');
clearLine2(5, offset);
clearLine2(5, offset + 2);
} while (!valid);
cin.setf(ios::skipws);
return input;
I simply can't find a solution for this and it's really causing some headaches, any help would be appreciated!