[Dev-C++] safe integer input. - follow up post
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Dane E. <dg...@wo...> - 2005-09-09 01:42:05
|
Hi,
I found this snippet and it seems to work well.
while ((cout << "\nYour selection: ")&& (!(cin >> userSelection)
|| userSelection < 0 || userSelection > employeeQuantity)) {
cout << "That's not a number between 1 and " <<
employeeQuantity << endl;
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
I suppose there are dangers to this?
Dane
da...@de...
|