How can I check if user has properly entered numbers not alphabets??

Hello, I've got some problems in checking whether the input data are numbers (double) or not!
I find that "strtod" will be useful...but as I'm a beginner of C++...I dont understand how to make it...I have no idea at all

I want to check the input of numbers, make sure they are numerical. IF the input isnt numerical, it should prompt for re-entry.
Can anybody generously give me a hand, please?
Thanks in advance!!! >.<

Last edited on
you could do isalpha().

That will return a boolean value T if all the characters in a string you tested are alpha. False otherwise.
Read this.
http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.3

You could write yourself a little template function called getInput or something to that effect which loops until the user enters valid data and prints a message when the user prints something invalid.
Last edited on
Thanks a lot oghmaosiris & kempofighter !!
I'll try it tonight!
Topic archived. No new replies allowed.