First of all, I would like to ask what are you trying to do:
cout<<cin.rdstate()<<endl;
rdstate()
http://www.cplusplus.com/reference/iostream/ios/rdstate/
:
, , , - , .
:
int main() {
string input = "";
cout << "Please enter a valid sentence (with spaces):\n>";
getline(cin, input);
cout << "You entered: " << input << endl << endl;
int myNumber = 0;
while (true) {
cout << "Please enter a valid number: ";
getline(cin, input);
stringstream myStream(input);
if (myStream >> myNumber)
break;
cout << "Invalid number, please try again" << endl;
}
cout << "You entered: " << myNumber << endl << endl;
char myChar = {0};
while (true) {
cout << "Please enter 1 char: ";
getline(cin, input);
if (input.length() == 1) {
myChar = input[0];
break;
}
cout << "Invalid character, please try again" << endl;
}
cout << "You entered: " << myChar << endl << endl;
cout << "All done. And without using the >> operator" << endl;
return 0;
}