Some Win32 API structures require to concatenate an extra null character to a string, as in the following example taken from here:
c:\temp1.txt'\0'c:\temp2.txt'\0''\0'
When it comes to wide strings, what is the easiest way to append a L'\0' to the end of an existing wide string?
Here's what works for me but seems too cumbersome:
wchar_t my_string[10] = L"abc";
size_t len = wcslen(my_string);
wchar_t nullchar[1] = {'\0'};
memcpy(my_string + len + 1, nullchar, sizeof(wchar_t));
my_stringis long enoughmy_string[wcslen(my_string)+1]='\0'?[c++], but your code seems more like C to me; e.g. in C++ you would usestd::wstring(which is capable of storing embedded nulls), instead of rawwchar_tC-style arrays.