#include #include using namespace std; int main(int argc, char **argv) { int status = EXIT_FAILURE; //guilty until proven innocent cout << "Please input an integer: "; int i; //uninitialized variable if (cin >> i) { //if (cin.operator>>(i).operator void *()) { cout << "The integer is " << i << ".\n"; status = EXIT_SUCCESS; } else { cout << argv[0] << ": integer input failed, "; if (cin.eof()) { cout << "eof\n"; } else if (cin.bad()) { cout << "bad\n"; } else if (cin.fail()) { cout << "fail\n"; } else { cout << "unknown\n"; } } cout << "operator>> did not eat the following characters: \""; cin.clear(); char c; //while (cin.get(c).operator void *() && c != '\n') { while (cin.get(c) && c != '\n') { cout.put(c); } cout << "\".\n"; return status; }