0

Connect LPCWSTRs

Hi, is it possible to connect two LPCWSTRs? e.g.: #include<Windows.h> #include<tchar.h> // ... LPCWSTR a = L"asdf"; LPCWSTR b = L"jklö"; LPCWSTR c = a + b; // error // ... doesn't work. Hope I will get some answers, S.A.

21st Nov 2020, 3:01 PM
Sebastian Ahlborn
Sebastian Ahlborn - avatar
2 odpowiedzi
+ 1
LPCWSTR -> Long Pointer Const Wide STRing = const wchar_t*. Can you use '+' operator on const char*/wchar_t*? you can't (unless you use C++ std::string/std::wstring or any other std/third party library). So, the way to add to the string/wide string would be using strcat/wcscat method. #include <iostream> #include <windows.h> #include <wchar.h> int main() { LPCWSTR a = L"hello "; LPCWSTR b = L"world!"; WCHAR buf[13]; wcscpy(buf, a); wcscat(buf, b); std::wcout << buf << L'\n'; return 0; }
21st Nov 2020, 6:33 PM
Flash