strtod
double strtod ( const char * string, char** endptr ); | stdlib.h |
cplusplus.com |
Convert string to double-precision floating-point value.
Parses string interpreting its content as a floating-point value until a character
that can not be interpreted is found,
and returns a double precision value.
Parameters.
Return Value.
The converted double value from the input string.
If conversion would cause overflow the result is +/- HUGE_VAL .
If an error occurs 0 is returned.
Portability.
Defined in ANSI-C.
Example.
/* strtod example */
#include <stdio.h>
#include <stdlib.h>
main ()
{
char szInput [256];
char * pEnd;
double dbl;
printf ("Enter a floating-point value: ");
gets (szInput);
dbl = strtod (szInput,&pEnd);
printf ("Value entered: %lf. Its square: %lf\n",dbl,dbl*dbl);
return 0;
}
See also.
atof,
strtol,
strtoul