Converts a given wide-character string to a double-precision number. Format #include <wchar.h> double wcstod (const wchar_t *nptr, wchar_t **endptr);
1 – Arguments
nptr A pointer to the wide-character string to be converted to a double-precision number. endptr The address of an object where the function can store the address of the first unrecognized wide character that terminates the scan. If endptr is a NULL pointer, the address of the first unrecognized wide character is not retained.
2 – Description
The wcstod function recognizes an optional sequence of white- space characters (as defined by iswspace), then an optional plus or minus sign, then a sequence of digits optionally containing a radix character, then an optional letter (e or E) followed by an optionally signed integer. The first unrecognized character ends the conversion. The string is interpreted by the same rules used to interpret floating constants. The radix character is defined in the program's current locale (category LC_NUMERIC). This function returns the converted value. For wcstod, overflows are accounted for in the following manner: o If the correct value causes an overflow, HUGE_VAL (with a plus or minus sign according to the sign of the value) is returned and errno is set to ERANGE. o If the correct value causes an underflow, 0 is returned and errno is set to ERANGE. If the string starts with an unrecognized wide character, *endptr is set to nptr and a 0 value is returned.
3 – Return Values
x The converted string. 0 Indicates the conversion could not be performed. The function sets errno to one of: o EINVAL - No conversion could be performed. o ERANGE - The value would cause an underflow. o ENOMEM - Not enough memory available for internal conversion buffer. HUGE_VAL Overflow occurred; errno is set to ERANGE.