Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int liczba;
- cout << "Podaj liczbe calkowita: ";
- cin >> liczba;
- while(cin.fail()) // zwraca true jeśli dane wejściowe są niepoprawne
- {
- cin.clear(); // usunięcie informacji o błędzie
- cin.ignore(9999, '\n'); // wyczyszczenie bufora wejścia
- cout << "Wpisano niepoprawna liczbe, wpisz jeszcze raz: ";
- cin >> liczba;
- }
- cout << "Wpisana liczba to " << liczba << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement