![]() |
VOOZH | about |
In C++, std::wstring is a type of string where each character is of a wide character type. Converting wstring to a double in C++ can be a common requirement especially when dealing with the inputs that are stored as unicode characters. In this article, we will learn how to convert a wstring to a double in C++.
Example
Input:
wstring input = L"3.14159"
Output:
Converted double value is: 3.14159
To convert a also known as wide string to a in C++, we can use the function provided by the . This function takes a string or wstring as input and returns the corresponding double value.
stod(wstring(str.begin(),str.end()));Here,
The following program illustrates how we can convert a wstring to a double value in C++.
Output
Converted double value: 3.15159
Type of result: d
Time Complexity: O(N), here N is the length of the wide string.
Auxiliary Space: O(1)