![]() |
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: Converting wstring to double in C++To convert a wstring also known as wide string to a double in C++, we can use the std::stod() function provided by the C++ STL library. This function takes a string or wstring as input and returns the corresponding double value. Syntax to Use std::stodstod(wstring(str.begin(),str.end())); Here,
C++ program to Convert a wstring to doubleThe following program illustrates how we can convert a wstring to a double value in C++.
Converted double value: 3.15159 Time Complexity: O(N), here N is the length of the wide string. |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 23 |