I am writing a code to take an integer ID from the user which is later validated from a file. Now when I don't enter a valid input in the cin it doesn't work (obviously). I have attached a sample code below like this:
std::cout << "Enter ID : " << std::endl;
std::cin >> id;
It's simple as that.
Now if I enter an input like a
or any other character, I can check for any error using cin.fail()
But if I enter an input like 11a
that doesn't seem to work. I have searched a lot on the internet but couldn't find any suitable solution.