Limiting user input to X decimal points

Greetings all.

First time poster. :)

Been doing a lot of reading on the forum and finding a lot of good information on how to format output to only show a certain number of decimal points or to round off (harder than I imagined I see).

What I can't seem to figure out is a way to limit a user's input to a certain number of decimal points.

For example, if you ask a user to input an amount of money, how do you idiot proof against the smartass who wants to put in 34.5634567 instead of 34.56?

Is there a way similar to cout.setprecision that works with cin?

Thanks
John
You can't. At least not with standard input. The best you can do is input into a string and cut off the string after the second digit, or truncate the value once you have it in the variable.
Topic archived. No new replies allowed.