Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

wcsncpy - copy wide character substring

&pagelevel(4)&pagelevel

Syntax

#include <wchar.h>

wchar_t *wcsncpy(wchar_t *ws1, const wchar_t *ws2, size_t n);

Description

wcsncpy() copies a maximum of n characters from the wide character string ws2 to the
memory area pointed to by ws1.

If the wide character string ws2 contains less than n characters, only the length of ws2
(wcslen + 1) is copied, and ws1 is then padded to the length of n with null wide character
codes.

If the wide character string ws2 contains n or more characters (excluding the null wide
character code), the wide character string ws1 is not automatically terminated with a null
wide character code.

If the wide character string ws1 contains more than n characters and the last character
copied from ws2 is not a null wide character code, any data which may still remain in ws1
will be retained.

wcsncpy() does not automatically terminate ws1 with a null wide character code.

Return val.

Pointer to the resulting wide character string ws1.

Notes

wcsncpy() does not verify whether ws1 has enough space to accommodate the result!

Since wcsncpy() does not automatically terminate the resulting wide character string with
a null wide character code, it may often be necessary to explicitly terminate ws1 with a null
wide character code. This is typically the case when only a part of ws2 is being copied, and
ws2 does not contain a null wide character code either.

The behavior is undefined if memory areas overlap.

Restriction
This version of the C runtime system only supports 1-byte characters as wide character
codes. They are of type wchar_t (see stddef.h). (End)

See also

wcscpy(), wchar.h.