Name
strtod function — Converts a string to double
Synopsis
double strtod(const char* str, char** end)
The strtod
function
converts a character array to a floating-point number. The string
str
is divided into three parts:
optional whitespace, the text of the floating-point value, and a
trailing part, which starts with the first character that cannot be
part of a floating-point number. The first part is skipped, and the
second part is converted to a floating-point value. If the second
part is empty, 0
is returned. If
end
is not null, *end
is assigned a pointer to the start of
the third part of str
. If the
third part is empty, *end
points
to the terminating null character.
If the result would cause overflow, positive or negative
HUGE_VAL
is returned, and
errno
is set to ERANGE
. If the result causes underflow,
0
is returned, and errno
is set to ERANGE
.
See Also
atoi function, strtol function, strtoul function, wcstod
in <cwchar>
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.