Annotations for "strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l" topic. Fri, 20 Dec 2013 03:25:57 Z Yuri V-v Return Value The description of return value as "Zero if successful, otherwise an error code" is suspicious. When we use _TRUNCATE, it's OK for return code to be STRUNCATE. I don't think that STRUNCATE is error code in such case. Fri, 08 Jan 2010 13:12:12 -0800 Vasiliy Zverev Size numberOfElements is a size in characters (where Unicode character is 2 bytes and ANSI character is 1 byte).You can use _countof(string_array) declared in &lt;stdlib.h&gt; to determine the size in elements of statically-allocated array.In Shangori's sample above the size should be calculated as DWORD size = helloLen + worldLen + 1; i.e. the size in elements of allocated buffer for result DWORD size = wcslen(result) * sizeof(wchar_t); is not correct becausea) it returns size in bytes, not in e Fri, 02 Oct 2009 12:06:41 -0700 Shangori Size in WORDs I agree with the comment above. When going through the headers, the following type surfaces: rsize_t. Thus the following example would be correct use:static LPCWSTR hello = L"Hello ";static const size_t helloLen = wcslen(ext); static LPCWSTR world = L"World";static const size_t worldLen = wcslen(font); LPWSTR result = (wchar_t*)(malloc(sizeof(wchar_t) * (helloLen + worldLen + 1)));DWORD size = wcslen(result) * sizeof(wchar_t);wcscpy_s(result, size, hello);wcscpy_s(name + helloLen, size, world); Tue, 28 Jul 2009 08:27:09 -0700 ThisIsARequiredField Size in bytes, or in characters...? numberOfElements The size of the destination string. "Number of elements" implies size in characters. "The size of" implies size in bytes. So which one is it? Characters, or bytes? The difference is important for MBCS and Unicode. Leaving this "minor" detail out of the documentation (and up to a programmer to guess) pretty much entirely defeats the purpose of having a "secure" version of these functions to begin with. Tue, 18 Nov 2008 22:11:47 -0800