Originally Posted by
Tamim Ad Dari
I couldnt find what I was looking for, I wanted to check whether the user has inputted an integer or string and reply accordingly..
Look at that link where it says "Error handling with IO streams"
You can also just read the user input into a string and then handle the input by checking first if it is a string. This separates the problem into first handling I/O and then interpreting I/O.
Code:
std::string input;
//get the input first
std::getline(std::cin, input);
//then use string stream to convert the input to number or any other method
int number;
std::stringstream sstr(input);
if (sstr >> input) {
//input contains the first integer the user inputted before pressing enter
}