Namespaces
Variants

std:: wmemcpy

From cppreference.net
헤더 파일에 정의됨 <cwchar>
wchar_t * wmemcpy ( wchar_t * dest, const wchar_t * src, std:: size_t count ) ;

정확히 count 개의 연속된 와이드 문자를 src 가 가리키는 와이드 문자 배열에서 dest 가 가리키는 와이드 문자 배열로 복사합니다. 객체가 겹치는 경우 동작은 정의되지 않습니다. 만약 count 가 0이면, 함수는 아무 작업도 수행하지 않습니다.

목차

매개변수

dest - 복사 대상 와이드 문자 배열에 대한 포인터
src - 복사 원본 와이드 문자 배열에 대한 포인터
count - 복사할 와이드 문자 수

반환값

dest

참고 사항

이 함수의 바이트 문자열에 대한 유사 함수는 std::strncpy 이며, std::strcpy 가 아닙니다.

이 함수는 로캘에 민감하지 않으며 복사하는 wchar_t 객체의 값에 주의를 기울이지 않습니다: null 문자와 유효하지 않은 문자들도 모두 복사됩니다.

예제

#include <clocale>
#include <cwchar>
#include <iostream>
#include <iterator>
#include <locale>
int main(void)
{
    const wchar_t from1[] = L"नमस्ते";
    const wchar_t from2[] = L"Բարև";
    const std::size_t sz1 = std::size(from1);
    const std::size_t sz2 = std::size(from2);
    wchar_t to[sz1 + sz2];
    std::wmemcpy(to, from1, sz1); // copy from1, along with its null terminator
    std::wmemcpy(to + sz1, from2, sz2); // append from2, along with its null terminator
    std::setlocale(LC_ALL, "en_US.utf8");
    std::wcout.imbue(std::locale("en_US.utf8"));
    std::wcout << L"Wide array contains: ";
    for (std::size_t n = 0; n < std::size(to); ++n)
        if (to[n])
            std::wcout << to[n];
        else
            std::wcout << L"\\0";
    std::wcout << L'\n';
}

가능한 출력:

Wide array contains: नमस्ते\0Բարև\0

참고 항목

한 문자열에서 다른 문자열로 특정 양의 문자를 복사합니다
(함수)
두 개의 배열(겹칠 수 있음) 사이에서 특정 양의 와이드 문자를 복사합니다
(함수)
C 문서 for wmemcpy