#include <is.h>

Karl Heuer karl at haddock.ima.isc.com
Wed Dec 21 14:27:19 AEST 1988


In article <1920 at paris.ics.uci.edu> nagel at blanche.ics.uci.edu (Mark Nagel) writes:
>... it would be nice to have something like this be part of the standard C
>library so that one could check validity of things like atoi, etc.

"Something like it" *is* in the Standard C library.  Check strtod() (for
floating point) and strtol() (for integer); each scans and evaluates its
string, and returns enough information to distinguish failure from valid
return values.

Btw, the posted version of the function accepts "3.14xyz" as valid (as does
atof() itself).  I would think that the problem as stated should require that
string to be rejected.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list