This question has already been answered:
- Check in the loop for correct input of integer 2 responses
I write a while in it there is a switch (the choice of case depends on a variable of type int ) if you enter a letter / symbol then the program crashes. It is necessary to implement a test for characters / letters ... Google, but did not find the answer intelligible. I myself sort of understand that I need to verify the type of the variable assigned, but alas, I cannot implement it. Implementing a simple check for labor numbers was not, but the letters / symbols are already a problem ...
while (ace) { std::cout << "Please select an action: "; std::cin >> a; switch (a) { case 1: { Sort1(); break; } case 2: { std::cout << "Hello 2" << std::endl; break; } case 3: { std::cout << "Hello 3" << std::endl; break; } case 4: { std::cout << "\nВы вышли из программы" << std::endl; system("pause"); ace = false; break; } default: std::cout << "Error" << std::endl; } }