Converts a wide string into a floating-point number #include <wchar.h> double wcstod ( const wchar_t * restrict wcs , wchar_t ** restrict endptr ); float wcstof ( const wchar_t * restrict wcs , wchar_t ** restrict endptr ); (C99) long double wcstold ( const wchar_t * restrict wcs , wchar_t ** restrict endptr ); (C99) The wcstod( ) function attempts to interpret the wide string addressed by its first pointer argument, wcs, as a floating-point numeric value, and returns the result with the type double. wcstof( ) and wcsold( ) are similar, but return float and long double respectively. Leading whitespace wide characters are ignored, and the string converted ends with the last wide character that can be interpreted as part of a floating-point numeral. The second parameter, endptr, is a pointer to a pointer. If its argument value is not a null pointer, then the function stores a pointer to the first wide character that is not part of the numeral converted in the location addressed by the endptr argument. (The locations that the function reads from and writes to using its restricted pointer parameters must not overlap.) If no conversion is possible, the function returns 0. If the resulting value exceeds the range of the function's type, then the return value is positive or negative HUGE_VAL (or HUGE_VALF or HUGE_VALL, for the float and long double variants). On an overflow, the errno variable is set to the value of ERANGE ("range error"). If the conversion produces an underflow, the magnitude of the return value is at most the smallest value greater than 0 that is representable in the function's return type, and the function may set the errno variable to the value of ERANGE ("range error"). The wide-character sequences that can be interpreted as floating-point numerals depend on the current locale. In all locales, they include those described in "Floating-Point Constants" in Chapter 3, and the sequence L"infinity", without regard to upper or lower case, or any sequence of letters, digits, and underscores that begins with L"nan", without regard to case. Examplewchar_t in[1024], *this = in, *next = in; double val; fputws( L"Enter some floating-point numbers, please:\n", stdout ); wscanf( L"%l[^\n]", in ); fputws( L"Here are the values you entered:\n", stdout ); while ( 1 ) { val = wcstod( this, &next ); if ( next == this ) // Means no conversion possible. break ; this = next; wprintf( L"\t%g\n", val ); } fputws( L"Done.\n", stdout ); See Alsowcstol( ), wcstoul( ), and wcstoimax( ); strtof( ), strtod( ), and strtold( ) |