
Convert a string to a double value ?
Quote:
> How can I convert a string to a double value ?
> I'm not sure wether "atof()" returns double value and I
> have heard about a function called "strtod()" ...
> How do I use it with which parameters ???
> Thanks !
Although others would tell you that CLC is not a replacement
for a good reference (K&R2 or C99 or some other C text book),
I'll give you a quote from the man page on my linux box:
#include <stdlib.h>
double strtod(const char *nptr, char **endptr);
DESCRIPTION
The strtod() function converts the initial portion of the
string pointed to by nptr to double representation.
The expected form of the string is optional leading white
space as checked by isspace(3), an optional plus (``+'')
or minus sign (``-'') followed by a sequence of digits
optionally containing a decimal-point character, option-
ally followed by an exponent. An exponent consists of an
``E'' or ``e'', followed by an optional plus or minus
sign, followed by a non-empty sequence of digits. If the
locale is not "C" or "POSIX", different formats may be
used.
Z
--
LISP is worth learning for the profound enlightenment experience you
will have when you finally get it; that experience will make you a
better programmer for the rest of your days. Eric S. Raymond