wmemcpy ()- 複製寬字元緩衝區
格式
#include <wchar.h>
wchar_t *wmemcpy(wchar_t *s1, const wchar_t *s2, size_t n);語言層次
ANSI
安全執行緒
是
寬字元函數
如需相關資訊,請參閱 寬字元 。
說明
wmemcpy() 函數會將 s2 所指向的物件中 n 個寬字元複製到 s1所指向的物件。 如果 s1 與 s2 重疊,則無法預期複製的結果。 如果 n 具有值 0 ,則 wmemcpy() 函數會複製 0 個寬字元。
回覆值
wmemcpy() 函數會傳回 s1的值。
範例
此範例會將前四個字元從 out 複製到 in。 在預期輸出中,這兩個字串的前四個字元都是 "ABCD"。
#include <wchar.h>
#include <stdio.h>
main()
{
wchar_t *in = L"12345678";
wchar_t *out = L"ABCDEFGH";
wchar_t *ptr;
printf("\nExpected result: First 4 chars of in change");
printf(" and are the same as first 4 chars of out");
ptr = wmemcpy(in, out, 4);
if (ptr == in)
printf("\nArray in %ls array out %ls \n", in, out);
else
{
printf("\n*** ERROR ***");
printf(" returned pointer wrong");
}
}