Advertisement
Levii_Valenok

Untitled

Oct 3rd, 2021
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1.  
  2. Product rightEnter()
  3. {
  4.     bool isRight = true;
  5.     int number;
  6.     while (isRight)
  7.     {
  8.         cout << "Enter an integer" << endl;
  9.         cin >> number;
  10.         if (cin.fail())
  11.         {
  12.             cin.clear();
  13.             cin.ignore(32767, '\n');
  14.             cout << "Incorrect value, try again" << endl;
  15.         }
  16.         else
  17.         {
  18.             isRight = false;
  19.         }
  20.     }
  21.     return number;
  22.  
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement