Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int enter_n() {
- int n;
- while (true)
- {
- cout << "Enter a n value: ";
- cin >> n;
- if (cin.fail())
- {
- cin.clear();
- cin.ignore(32767,'\n');
- cout << "Oops, that input is invalid. Please try again.\n";
- }
- else
- {
- cin.ignore(32767,'\n');
- return n;
- }
- }
- }
Add Comment
Please, Sign In to add comment