Concatenation of LPWSTR strings

2020-02-13 08:24发布

问题:

In Visual C++, I have a

LPWSTR mystring;

which is already defined somewhere else in the code.

I want to create a new LPWSTR containing:

"hello " + mystring + " blablabla"        (i.e. a concatenation)

I'm getting mad with such a simple thing (concatenation)! Thanks a lot in advance, I'm lost!

回答1:

The C++ way:

std::wstring mywstring(mystring);
std::wstring concatted_stdstr = L"hello " + mywstring + L" blah";
LPCWSTR concatted = concatted_stdstr.c_str();


回答2:

You can use StringCchCatW function