#include <stdlib.h> double strtod(const char *s, char **endp);
This function converts as many characters of s as look like a
floating point number into that number. If endp is not a null
pointer, *endp
is set to point to the first unconverted
character.
The value the represented by s.
If a number represented by s doesn't fit into the range of values
representable by the type double
, the function returns either
-HUGE_VAL
(if s begins with the character -
) or
+HUGE_VAL
, and sets errno
to ERANGE
.
ANSI, POSIX
char *buf = "123ret"; char *bp; double x = strtod(buf, &bp);
Go to the first, previous, next, last section, table of contents.