函式
<cwchar>

wmemcpy

wchar_t* wmemcpy (wchar_t* destination, const wchar_t* source, size_t num);
複製寬字元塊
source 指向的位置複製 numwchar_t型別元素的值到 destination 指向的位置。

該函式不檢查 source 中的任何終止空寬字元——它總是精確複製 numwchar_t.

型別的元素。為避免溢位,destinationsource 引數所指向的陣列大小都應至少為 numwchar_t型別元素,並且不應重疊(對於重疊的記憶體塊,wmemmove 是更安全的方法)。

這是 memcpy (<cstring>) 的寬字元等價版本。

引數

destination
指向要複製內容的目標陣列的指標。
source
指向要複製的資料來源的指標。
num
要複製的位元組數。
size_t 是一個無符號整數型別。

返回值

返回 destination

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* wmemcpy example */
#include <wchar.h>

int main ()
{
  wchar_t wcs1[] = L"To be or not to be";
  wchar_t wcs2[40];
  wchar_t wcs3[40];

  wcsncpy ( wcs2, wcs1, 40 );  /* copies 19 characters, then fills with L'\0' */
  wmemcpy ( wcs3, wcs1, 40 );  /* copies 40 characters */

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

  return 0;
}

輸出
To be or not to be
To be or not to be
To be or not to be


另見