How to check the output cin?

#include <iostream>
#include <string>
using namespace std;

int main() {
 int a, b;

 cout << "write a \n";
 cin >> a;
 cout << "write b \n";
 cin >> b;

 if (a > b) {
 cout << a << "a bolshe \n";
}
 else if (a == b) {
 cout << a << "ravno" << b << "\n";
}
 else if (a < b) {
 cout << b << "b bolshe \n";
}
 else {
 cout << "ERROR \n";
}

system("pause");
 return 0;
}</string></iostream>


Is there a primitive code, in compilations for example, if output y then
write a
y
write b
Ravno -858993460 -858993460


How to check the output of cin and if not figure something else ?
June 14th 19 at 20:17
1 answer
June 14th 19 at 20:19
Read in a line or 1 character and analyze every character entered.
You are now read directly int.

Find more questions by tags C++