I am using a function to check that my input in an integer only:
int input; while (true) { std::cin >> input; if (!std::cin) { std::cout << "Bad Format. Please Insert an integer! " << std::endl; std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); continue; } else return input; } However when inputing a integer followed by a char, eg. 3s, the integer gets accepted and the message gets printed.
How can I make sure that the input in such format does not get accepted, nor do input in form 4s 5, so when the integer appears after the space.
std::getlineand unsure parsed line is empty afterward?std::cininto a string and validate the string using regex or something.