Check the type of input

Hello everyone, can you help me with this?
In my program, there are some int and double variables. Here is my problem. When users input a double variable for an int variable, I must display an announcement for their mistake. How can I know the type of the value given by users?
I think I'll use string, and check whether it has a dot (.) or not. Do we have any better way?
Thanks for your help!
Am actually a newbie. But I would suggest you include a message telling your users the type of variable to input. For example
cout <<"please input an integer";
Try: cin.fail(), cin.bad(), cin.clear()
Use std::getline(), an std::istringstream, and eof()
http://www.cplusplus.com/forum/beginner/13044/page1.html#msg62827
Topic archived. No new replies allowed.