Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<limits>
- using namespace std;
- int main()
- {
- cout << "Enter an int: ";
- int x = 0;
- while(!(cin >> x)){
- cin.clear();
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- cout << "Invalid input. Try again: ";
- }
- cout << "You enterd: " << x << endl;
- }
Add Comment
Please, Sign In to add comment