#include <is.h>

Guy Harris guy at auspex.UUCP
Thu Dec 22 17:26:38 AEST 1988


>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.

Also note that "strtod" can be used in code that would reject this
string.  It stops scanning at the first unrecognized character; for
instance, if the floating-point number is expected to be terminated by a
white-space character or by a '\0' (i.e., it's expected to be a token in
a string, with tokens delimited by white space), the caller of "strtod"
would pass it a non-NULL second argument that pointed to a "char *"
variable initialized to point to the string; if, after calling "strtod",
the "char *" variable still pointed to the string, or pointed to a
character that wasn't white space or '\0', the string should be rejected.



More information about the Comp.lang.c mailing list