Answers for "how to make sure the user inputs a int and not anything else c++"

C++
1

how to make sure the user inputs a int and not anything else c++

int x;
    std::cin >> x;
    while(std::cin.fail()) {
        std::cout << "Error" << std::endl;
        std::cin.clear();
        std::cin.ignore(256,'\n');
        std::cin >> x;
    }
Posted by: Guest on June-10-2020

Code answers related to "how to make sure the user inputs a int and not anything else c++"

Browse Popular Code Answers by Language