标签:streams ams corrupt class clear highlight fail NPU limit
void test1(void) { int number; cout << ">> pls input a integer number:"; while(cin >> number, !cin.eof()) { if(cin.bad()) { cout << "stream has corrupted!" << endl; return; } else if (cin.fail()) { cin.clear(); cin.ignore(std::numeric_limits<std::streamsize>::max(), ‘\n‘); cout << ">> pls input a integer number:"; continue; } cout << "number = " << number << endl; } }
标签:streams ams corrupt class clear highlight fail NPU limit
原文地址:https://www.cnblogs.com/cthon/p/9315269.html