c++ adding two wchar_t vars
windows platform. szPath is pre defined. i want to add szPath2 to it but i don't want to use the PathApp开发者_开发技巧end function because i 'll need to link the Shlwapi library.
what should i do? i want to return a wchat_t..
wchar_t szPath[MAX_PATH];
wchar_t szPath2[MAX_PATH] = L"\\project\\MyApplication.exe";
Any reason you aren't using std::wstring
?
You can also use wcsncat
Use the standard wide-char concatenation function, wcscat
or any of its friends as appropriate.
Use wcscat
. The signature of the function is as follws. If you know strcat
, it's the same function but works with whcar_t
instead.
wchar_t *wcscat (wchar_t *dest, const wchar_t *src);
It will put src
at the end of dest
and handle the null terminating character as well. Of course, dest
should have sufficient space available, and the two arrays shouldn't overlap.
See MSDN article on string concatenation for further details.
精彩评论