Advertisement
MeehoweCK

Untitled

Jul 15th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout << "Prosze podac liczbe calkowita: ";
  8.     int liczba;
  9.     cin >> liczba;
  10.     while(cin.fail())
  11.     {
  12.         cout << "Podana liczba nie byla prawidlowa, podaj jeszcze raz: ";
  13.         cin.clear();                // opuszcza flagę błędu
  14.         cin.ignore(9999, '\n');     // czyści bufor wejścia z dotychczas wpisanych znaków
  15.         cin >> liczba;
  16.     }
  17.     cout << liczba << endl;
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement