C
onverts a string to a single-precision floating-point value.
#include <stdlib.h> float strtof(const char *nptr, char **endptr); #include <wchar.h> float wcstof(const wchar_t *nptr, wchar_t **endptr);
nptr
endptr
strtof expects nptr
to point to a string with this form:
[whitespace][sign][digits][.digits][{d|D|e|E}[sign]digits]
The first character that does not fit this form stops the scan.
If no conversion can be performed (no valid digits are found or an invalid base is specified), the value of nptr
is stored at the location pointed to by endptr
.
strtof
returns the value of the floating-point number, except when the representation would cause an overflow, in which case the function returns +/–HUGE_VALF
. The sign of HUGE_VALF
matches the sign of the value that cannot be represented. strtof
returns 0 if no conversion can be performed or an underflow occurs.
wcstof
returns values analogously to strtof
. For both functions, errno
is set to ERANGE
if overflow or underflow occurs.
tchar.h routine |
_UNICODE not defined |
_UNICODE defined |
---|---|---|
_tcstof | strtof | wcstof |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 INtime 6.0 (wide-character and generic text versions) |
intime/rt/include/stdlib.h intime/rt/include/wchar.h intime/rt/include/tchar.h |
stdlib.h wchar.h tchar.h |
clib.lib |