The following code loops forever once I enter the failbit test.
After some reading I entered cin.ignore() before the continue statement and even tried to pass gcount() to ignore() first argument. To no avail. Also, literal integers passed to ignore() seem to have the effect of only working if I match the exact lenght of the string introduced...Code:int ival; while (cin >> ival, !cin.eof()) { if (cin.bad()) throw runtime_error("Corrupted IO Stream."); if (cin.fail()) { cerr << "bad data, try again..."; cin.clear(istream::failbit); continue; } /* ... */ }
What should be done?



LinkBack URL
About LinkBacks



