In the following example, I want the user to input something like:
1 + 2 = 3, then (not included) test its validity.
string op, eq;
int num1, num2, user_result;
cout<<"Please key in your equation.";
cin >> num1>>op>>num2>>eq>>user_result;
However, I need to "invalid input" this kind of input:
1 + 2 = 3 + 0
I can't think how to test for the extra bit. I tried an additional variable then checking if it was nul, but obviously, the program waits for the extra input.
Is there a way to check if there is extra input? I thought of getline(cin, s) or something, but thats for strings.