The only way I am aware of by achieving this is to input straight into a string and then use some validation and functions to check whether it is an integer or not. If you input straight into an integer it would take everything up to an invalid character that can't be stored in an integer like a letter for example. But then if it was a string it would have been lost.
So the best way I know is to input into a string and do some checks on it by maybe using the std::stoi() string function or a custom written function you made yourself.
pnoid but what I'm trying to accomplish is for the program itself to detect whether the data that's being inputted is an integer or a string. I want the user to only have to input one thing.