Name

wcsncpy

Synopsis

Copies the first n wide characters of a string to another location

#include <wchar.h>
wchar_t *wcsncpy( const wchar_t * restrict dest,
                  const wchar_t * restrict src, size_t n );

The wcsncpy() function copies at most n wide characters from the string addressed by src to the wchar_t array addressed by dest, which must be large enough to accommodate n wide characters. The wcsncpy() function returns the value of its first argument, dest. The locations that wcsncpy() reads from and writes to using its restricted pointer parameters must not overlap.

Tip

If there is no null wide character within the first n characters of src, then the copied string fragment is not terminated.

If wcsncpy() reads a null wide character from src before it has copied n wide characters, then the function writes null wide characters to dest until it has written a total of n wide characters.

Example

See the examples for wcscspn() and wcspbrk() in this chapter.

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.