函式
<cwchar>

wcscpy

wchar_t* wcscpy (wchar_t* destination, const wchar_t* source);
複製寬字串
source 指向的 C 風格寬字串複製到 destination 指向的陣列中,包括結尾的空字元(並在該點停止)。

為避免溢位,destination 指向的陣列大小必須足夠長,以包含與 source 相同的 C 風格寬字串(包括結尾的空字元),並且在記憶體中不應與 source 重疊。

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

引數

destination
指向要複製內容的目標陣列的指標。
source
要被複制的 C 風格寬字串。

返回值

返回 destination

示例

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

int main ()
{
  wchar_t wcs1[]=L"Sample string";
  wchar_t wcs2[40];
  wchar_t wcs3[40];
  wcscpy (wcs2,wcs1);
  wcscpy (wcs3,L"copy successful");
  wprintf (L"str1: %ls\nstr2: %ls\nstr3: %ls\n",wcs1,wcs2,wcs3);
  return 0;
}

輸出

str1: Sample string
str2: Sample string
str3: copy successful


另見