The wcstod() function converts the wide string as a double. This function interprets the contents of a wide string as a floating point number. If endString is not a null pointer, the function also sets the value of endString to point to the first character after the number.
double wcstod( const wchar_t* str, wchar_t** str_end )
Parameters: The function accepts two mandatory parameters which are described below:
- string: specifies the string which begins with the representation of a floating-point number
- endString: specifies the pointer to a wide character
Return value: The function returns two value as below:
- On success, the function returns the converted floating point number as a value of type double.
- If no valid conversion could be performed, it returns 0.0 .
- If the correct value is out of the range of representable values for the type, a positive or negative HUGE_VAL is returned, and errno is set to ERANGE.
- If the correct value would cause underflow, the function returns a value whose magnitude is no greater than the smallest normalized positive number (some library implementations may also set errno to ERANGE in this case).
Below programs illustrate the above function:
Program 1 :
String -> 95.6Geek Double value -> 95.6 End String is : Geek
Program 2 :
String -> 10.6464 Double value -> 10.6464 End String is :
Program 3 :
String -> 99.999Geek Double value -> 99.999 End String is : Geek
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- What happens when a virtual function is called inside a non-virtual function in C++
- Function Overloading vs Function Overriding in C++
- Difference between Virtual function and Pure virtual function in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between user defined function and library function in C/C++
- Difference between virtual function and inline function in C++
- Can we call an undeclared function in C++?
- Can we use function on left side of an expression in C and C++?
- Declare a C/C++ function returning pointer to array of integer pointers
- Function overloading and return type
- Function Pointer in C
- Default arguments and virtual function
- Function overloading and const keyword
- How to measure time taken by a function in C?
- Comparator function of qsort() in C
- Can we access private data members of a class without using a member or a friend function?
- Function Overloading and float in C++
- Extra brackets with function names in C/C++
- Function Interposition in C with an example of user defined malloc()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.