Do not use sizeof winTitle
as-is.
The _stprintf_s
function requires the number of characters
, not the number of bytes
.
http://msdn.microsoft.com/en-us/library/ce3zzk1k.aspx
Since obviously you're using TCHAR, then the number of characters is as follows:
sizeof(winTitle) / sizeof(winTitle[0])
or
sizeof(winTitle) / sizeof(TCHAR)
A TCHAR in the MS world is either going to be 1 byte (if the build is MBCS) or 2 bytes (which is Unicode).
Assuming you're using Unicode, by just stating sizeof winTitle
, you are specifying that your array can fit a maximum of 200 characters, but that is not true (display what sizeof winTitle
gives you, and you will see it is 200).