IS there anyway i can test or check if a user enters a certain data type...?

wondering if there's a way i can test if.... a user enters a certain <data type>... to execute some code(i.e function calling,print something..ask for some other input..ect.).


???can you show me if there's something like this.
in c++

example ...say if a user enters char or float input...... call this function.




thanks in advance.
There's an article by zaita in the articles forum on managing user input using cin. What I'd imagine is that you'd get a string, and then determine what the input is based on its length, contents, etc. If it was all digits except one period, you could assign it to a double. All digits with no period is an int. A single character, not a digit, would be a char (but so could a single digit, which is why you'd need more information than user input alone). Anything else... string, I guess.
You can't get an "indeterminate" data type, if that's what you had in mind.
or just use the isdigit(), isalpha() functions. I love this functions, they do wonders for simple expression parsers.
Topic archived. No new replies allowed.