wcsncpy Function

Copy a wide string to an array.

Attention: This function is implemented only by MPLAB XC32 C compilers.

Include

<wchar.h>

Prototype

wchar_t * wcsncpy( wchar_t * restrict s1, const wchar_t * restrict s2, size_t n);

Arguments

s1
the array to hold the copied wide string
s2
the wide string to copy
n
the maximum number of wide characters to copy

Return Value

A copy of s1.

Remarks

The function copies the wide string pointed to by s2 into the array s1. No further wide characters are read from s1 if n wide characters have been copied or a null wide character has been copied. If less than n wide characters have been written to s1, null wide characters are appended to s1 until it is n wide characters wide.

Example

#include <wchar.h>

int main(void)
{
  wchar_t ws[40];

  wcsncpy(ws, L"a literal wide string", 40);
  wprintf(L"the wide string referenced by ws is \"%ls\"\n", ws);
}

Example Output

the wide string referenced by ws is "a literal wide string"