C examples for wchar.h:wcsncpy
function
<cwchar> <wchar.h>
Copy characters from wide string
wchar_t* wcsncpy (wchar_t* destination, const wchar_t* source, size_t num);
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. |
destination is returned.
#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; }