How to anticipate single or multiple input failure(s) when input(s) are read in using C++ std::cin and extraction operator >>
Hello SoloLearners, I'm asking this question because I need suggestions on how to anticipate input failure when reading in multiple data using chained extraction operator >> Let's see an example so we could stay on the same boat. Assume the snippet in main() function body, with necessary headers included. int n1, n2, n3; std::cin >> n1 >> n2 >> n3; How do I deal when: 1. User input nothing. 2. User input 3 values, but none of the values were valid subject for conversion to integer. 3. User input 1 or 2 valid integers, rest are no valid subject for conversion to integer. 4. User input only 1 valid integer, rest are no valid subject for conversion to integer. I'm curious, is it possible for me to know how many values are successfully read-in and converted to integers (C scanf() supports that). Also if possible, I would like to know which, amongst the 3 variables (n1, n2 and n3) has a valid data, so I wouldn't be using ones that contains invalid data. Thank you, in advance ...