-
More strtod troubles
Some time ago I got some help and the suggestion was given to use strtod to validate floating point input from a dialog box.
http://cboard.cprogramming.com/showt...threadid=28651
Now, I am well on my way writing this program when I realize that the user could very well wish to input zero and since the strtod function returns zero on failure this is probably not the best solution.
Why in the world would it return zero if zero could be a valid input? Am I missing the point?
-
What you had originally to check the validity of user input was fine - checking valid input and converting that input to a double are two different things. I would use both.
Code:
if (is_valid_double(pbuffer))
{
double val = strtod(pbuffer);
...
}
Don't forget about negative numbers....if that's valid input.
gg
-
Thanks Codeplug!
...for keeping me on the right track.