#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <Windows.h>
int main(void)
{
TCHAR greeting[50] = L"Hello world";
TCHAR exclamation=L'!';
//????
wprintf("%s",greeting);
return 0;
}
What should be done, so that the output would be greeting with the exclamation mark? Instruction
greeting[wcslen(greeting)]=exclamation; fulfils the remaining part of array with Chinese characters.
PS. I need to output only “greeting” variable, so the code except of //???? is unalterable.
At
greeting[wcslen(greeting)]there is a null terminator characterL'\0', signaling the end of the string. Whatever is besides that point is undefined (chinese characters seems to be in your case). What you need to do is move such null terminator to the next position in the array.Note that you have to do it in that order, or otherwise
wcslenwould give a different (indeterminated) value. If you used the standard append functions, this would be done for you.