Advertisement
Guest User

xxx

a guest
Nov 25th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {   int liczba ;
  8.    
  9.     cout<<"Podaj liczbe: ";
  10.     cin>>liczba;
  11.  
  12.         if(!(cin>>liczba)) //dopóki strumień jest w stanie błędu -> dopóki podawane są błędne dane
  13. {
  14.   cout<<"Niepoprawny znak. Podaj liczbe!: ";//ew komunikat błędu
  15.   cin.clear(); //kasowanie flagi błędu strumienia
  16.   cin.sync(); //kasowanie zbędnych znaków z bufora
  17. }
  18.         else
  19.  
  20.     cout<<"Podana liczba to: "<<liczba<< endl;
  21.    
  22.         system("pause");
  23.         return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement