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));
assuming my_string is long enough:
The terminating null will be translated to a wide char.
(Posted as a first comment to the question)