strtod

Syntax

double strtod(const char* nptr, char** endptr)

Arguments

nptr
Pointer to the string containing the value to convert.
endptr
Optional storage space for output by this function.

Return

The converted value from the string.

Description

This function will convert a string to a double value.
The string is expected to have optional leading white space followed by an optional plus (+) or minus (-) character, any number of digits including a single decimal point and optionally an exponent which consists of either an E or e, an optional plus or minus sign and one or more digits.
If endptr is not NULL, a pointer to the next character after the parsed portion of the string is stored in the memory location reference by endptr.
If the resultant value would overflow the boundaries of the double datatype, the maximum possible value is returned. If an underflow would occur, zero will be returned. In both cases an errorcode will be set which can be queried.

Also see

strtol, strtoul

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.