memmove_s, wmemmove_s

하나 이상의 버퍼를 다른 위치로 이동 합니다.이러한 버전의 있습니다 memmove, wmemmove 와 보안 기능 향상에 설명 된 대로 CRT의 보안 기능.

errno_t memmove_s(
   void *dest,
   size_t numberOfElements,
   const void *src,
   size_t count
);
errno_t wmemmove_s(
   wchar_t *dest,
   size_t numberOfElements,
   const wchar_t *src,
   size_t count
);

매개 변수

  • dest
    대상 개체입니다.

  • numberOfElements
    대상 버퍼의 크기입니다.

  • src
    소스 개체입니다.

  • count
    바이트 (memmove_s) 또는 문자 (wmemmove_s) 복사 합니다.

반환 값

성공 하는 경우에 0입니다. 실패 시 오류 코드

오류 조건

dest

numberOfElements

src

반환 값

내용dest

NULL

모든

모든

EINVAL

수정 되지 않음

모든

모든

NULL

EINVAL

수정 되지 않음

모든

< count

모든

ERANGE

수정 되지 않음

설명

복사 count 바이트의 문자 수를 src 에 dest*.* 원본 영역과 대상의 일부 영역으로 겹칠 경우 memmove_s 원본 소스 바이트 겹치는 영역에 덮어쓰기 전에 복사 됩니다.

경우 dest 또는 src 는 null 포인터 이거나 대상 문자열이 너무 작은 경우이 함수는 잘못 된 매개 변수 처리기의 설명에 따라 호출 매개 변수 유효성 검사 .다음이 함수 실행 계속할 수 있는지 여부를 반환 EINVAL 를 설정 하 고 errno 에 EINVAL.

요구 사항

루틴

필수 헤더

memmove_s

<string.h>

wmemmove_s

<wchar.h>

추가 호환성 정보를 참조 하십시오. 호환성 소개에서 합니다.

예제

// crt_memmove_s.c
//
// The program demonstrates the 
// memmove_s function which works as expected
// for moving overlapping regions.

#include <stdio.h>
#include <string.h>

int main()
{
   char str[] = "0123456789";

   printf("Before: %s\n", str);

   // Move six bytes from the start of the string
   // to a new position shifted by one byte. To protect against
   // buffer overrun, the secure version of memmove requires the
   // the length of the destination string to be specified. 

   memmove_s((str + 1), strnlen(str + 1, 10), str, 6); 

   printf_s(" After: %s\n", str);
}

Output

Before: 0123456789
 After: 0012345789

해당 .NET Framework 항목

System::Buffer::BlockCopy

참고 항목

참조

버퍼 조작

_memccpy

memcpy, wmemcpy

_mbscpy_s, wcscpy_s strcpy_s

strcpy, wcscpy, _mbscpy

strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l

strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l