cin >> num;
while (cin.fail() || num < 0 || num > 999999) // child proofing
{
cout << " ERROR: wrong/invalid input try again ";
cin.clear(); // reset any flag errors in the cin
cin.ignore(INT_MAX, '\n');
cin >> num;
}
if I enter a combination of integers and letters it will ignore the letters and input the numbers
Input: 1234ekl
Output: 1234
Input: 12wr43
Output: 12
I need a way to check the input so I could as for a valid one in case its not.