Input checking for variable types

I have a section of code that needs to work like this in C++.

What it does is take the input from a variable to store it in an integer. What I need to do is check that the input was indeed a number, and not a character or string or double. How do I check that the user input was in the correct format instead of just watching my program crumble?

Thanks,

G
[382 byte] By [geehumshriber] at [2007-11-20 11:14:34]
# 1 Re: Input checking for variable types
I have a section of code that needs to work like this in C++.

What it does is take the input from a variable to store it in an integer. What I need to do is check that the input was indeed a number, and not a character or string or double. How do I check that the user input was in the correct format instead of just watching my program crumble?Read the data in as a string, then use strtol or strtoul functions.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:25:18 >