atof, strtod - Converts a character string to a double-precision floating-point value
Standard C Library (libc.a)
const char *nptr) ;
const char *nptr,
char **endptr) ;
Points to the character string to convert. Specifies either a null value, or a pointer to the character that ended the scan or to a null value.
The atof() function converts the string pointed to by the nptr parameter up to the first character that is inconsistent with the format of a floating-point number to a double floating-point value. Leading white-space characters are ignored. A call to this function is equivalent to a call to strtod(nptr, (char **) NULL), except for error handling. When the value cannot be represented, the result is undefined.
The strtod() function converts the initial portion of the string pointed to by the nptr parameter to double representation. First the input string is decomposed into the following three parts: An initial, possibly empty, sequence of white-space characters (as specified by the isspace() function). A subject sequence interpreted as a floating-point constant. A final string of one or more unrecognized characters, including the terminating null character of the input string.
After decomposition of the string, the subject sequence is converted to a floating-point number, and the resulting value is returned. A subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The expected form and order of the subject sequence is: An optional plus (+) or minus (-) sign. A sequence of digits optionally containing a radix character. An optional exponent part. An exponent part consists of e or E, followed by an optional sign, which is followed by one or more decimal digits.
When the input string is empty or consists entirely of white space, or when the first nonwhite-space character is other than a sign, a digit, or a radix character, the subject sequence contains no characters.
For the strtod() function, when the value of the endptr parameter is not (char**) NULL, a pointer to the character that terminated the scan is stored at *endptr.
When a floating-point value cannot be formed, *endptr is set to nptr.
The setlocale() function may affect the radix character used in the conversion result. Full use
When the string is empty or begins with an unrecognized character, +0.0 is returned as the floating-point value.
When a correct return value overflows, a properly signed HUGE_VAL (INF) is returned. On underflow, a properly signed 0 (zero) is returned.
Upon successful completion, either function returns the converted floating-point value.
If the atof() or strtod() function fails, errno may be set to the following value: The input string is out of range (that is, the subject sequence can not be converted to a floating-point value without causing underflow or overflow).
Functions: atoi(3), scanf(3) delim off