my code is:
int num;
string check = "true";
cin >> num;
if (cin.fail())
check = "false";
cout << check;
}
I want to make sure the input is an integer only. When the input is like r3 (non-digits followed by integer), the output is false. But when the input is like 3r (digits followed by non-digits), the output is true. How to solve this problem?