int year;
std::cout << "Enter a year: ";
if (std::cin.good())
std::cout << "you enter " << year << '\n';
else
std::cout << "Wrong input" << '\n';
while (!(std::cin >> year)) {
        std::cin.clear();
        std::cin.ignore(100, '\n');
        std::cout << "must be integer, reinput" << '\n';
        std::cout << "Enter a year: ";
}| 欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |