wcsncpy - C wchar.h

C examples for wchar.h:wcsncpy

Type

function

From


<cwchar>
<wchar.h>

Description

Copy characters from wide string

Prototype

wchar_t* wcsncpy (wchar_t* destination, const wchar_t* source, size_t num);

Parameters

Parameter Description
destination Pointer to the destination array where the content is to be copied.
source C wide string to be copied.
num Maximum number of wide characters to be copied from source.

Return Value

destination is returned.

Demo Code


#include <wchar.h>

int main ()// w w  w .  j  a  v a2s  .  c  o m
{
  wchar_t wcs1[] = L"this is a test test test this is a test";
  wchar_t wcs2[40];
  wchar_t wcs3[40];

  wcsncpy ( wcs2, wcs1, 40 );

  wcsncpy ( wcs3, wcs2, 5 );

  wcs3[5] = L'\0';   /* null character manually added */

  wprintf (L"%ls\n%ls\n%ls\n",wcs1,wcs2,wcs3);

  return 0;
}

Related Tutorials