I have built up a string using wstringstream and need to assign it to a member of a struct of type LPWSTR. I try to use my_stringstream.str().c_str() but get the following compile time error:
cannot convert from ‘const wchar_t *’ to ‘LPWSTR’
How can I do this? I have tried many different combinations of casts with either more compile time errors or random jargon when I try and display the string in a GUI.
Your function expects a pointer to modifiable data, i.e.
wchar_t*, but the standard string class only exposes a pointer to constant. Assuming that your function may actually write to the memory, we need to provide it with a valid pointer.An easy way to obtain a modifiable buffer is, as always, a
vector: