wcscpy ()- 複製寬字元字串
格式
#include <wchar.h>
wchar_t *wcscpy(wchar_t *string1, const wchar_t *string2);語言層次
XPG4
安全執行緒
是
寬字元函數
如需相關資訊,請參閱 寬字元 。
說明
wcscpy() 函數會將 string2 (包括結尾 wchar_t 空值字元) 的內容複製到 string1。
wcscpy() 函數會處理以空值結尾的 wchar_t 字串; 此函數的字串引數應該包含 wchar_t 空值字元標示字串結尾。 只有 string2 需要包含空值字元。 未執行界限檢查。
回覆值
wcscpy() 函數會傳回指向 string1的指標。
範例
此範例會將 source 的內容複製到 destination。
#include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t source[ SIZE ] = L"This is the source string";
wchar_t destination[ SIZE ] = L"And this is the destination string";
wchar_t * return_string;
printf( "destination is originally = \"%ls\"\n", destination );
return_string = wcscpy( destination, source );
printf( "After wcscpy, destination becomes \"%ls\"\n", destination );
}
/**************** Output should be similar to: ******************
destination is originally = "And this is the destination string"
After wcscpy, destination becomes "This is the source string"
*/