C++ Fix for checking if input is an integer
for example, if I enter "2a", it does not show an error nor asks the user
to re-input the value. how do i fix this?
while (std::cin.fail())
{
std::cout << "ERROR, enter a number" << std::endl;
std::cin.clear();
std::cin.ignore(256,'\n');
std::cin >> dblMarkOne;
}
std::cout << "" << std::endl;
No comments:
Post a Comment