The C++ standard library provides the wstring class that is used to manipulate wide character strings. The c_str() member function of the wstring class returns a constant pointer to a null-terminated array of wide characters representing the string.
Example:
#include #include
int main() { std::wstring myString = L"Hello world!";
const wchar_t* cString = myString.c_str();
std::wcout << L"The string is: " << cString << std::endl;
return 0; }
This example demonstrates how to use the c_str() member function to get a constant pointer to a wide character array representing a wstring object. The code prints the string to the console using wcout.
The package library used in this example is the C++ standard library, which is included in all C++ compilers.
C++ (Cpp) wstring::c_str - 30 examples found. These are the top rated real world C++ (Cpp) examples of std::wstring::c_str extracted from open source projects. You can rate examples to help us improve the quality of examples.