Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <limits>
- int main()
- {
- int age = 0;
- while ((std::cout << "How old are you? ")
- && !(std::cin >> age)) {
- std::cout << "That's not a number; ";
- std::cin.clear();
- std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
- }
- std::cout << "You are " << age << " years old\n";
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement