how can my program identify if input is a double or a int?

i want my program to accept ONLY double value and if the user put in a int the program dont accept it. how can i make my program do this?
if you're querying the user for input, and want that input to be stored as a double by the program, you could just use
1
2
double x;
cin >> x;


Even if the user enters the value '23', it will still get stored as a double '23.0'.

If, however, you want to enforce input in a particular format, such as ##.# (requiring at least one value after the decimal place), you can receive the input into a string, parse that string to verify it's the appropriate format, then dump it into a double.
Topic archived. No new replies allowed.