Of the two, I'd use atof instead of sscanf, just because a simpler
interface is harder for implementers to screw up.
atof & strtod are both std C, but atof long predates the C std so is
available on more platforms. It's hard to imagine that any platform
supports the new strtod but not the old (but still required) atof.
If you verify the format of the string yourself, you're still vulnerable
to poor or incorrect range checking in the implementation, but there's
little you can do about that short of what you already tried to
accomplish with O'Keefe's strtod. Provided atof does it correctly, note
that both overflow & underflow set errno to ERANGE; the difference is
that underflow returns 0. What overflow returns isn't clear (sometimes an
infinity on an IEEE machine; sometimes the largest finite; sometimes
nonsense, although that's definitely an error in the implementation, &
ditto if atof ever blows up).
no-easy-answers-here-ly y'rs - tim
Tim Peters email@example.com
not speaking for Kendall Square Research Corp