Im writing a C program that accepts some values as command line arguments and performs some calculations on them.
I need the strings read form the command line to be converted to float or double (whichever). That's not a problem. Using either atof() or strtof() (or atod() and strtod()) works fine.
My main problem is trying to handle the error if the user does not enter a floating poin value. I read the specification for strtod() to capture errors but i can't make head or tail of it. Could someone please explain how the error checking part of these functions works?
(e.g.: if the user enters "hello" instead of "5.54353" i need to be able to respond and print and error message saying "floating point value not entered".)
Thanks in advance.