memmove() — 바이트 복사

형식

#include <string.h>
void *memmove(void *dest, const void *src, size_t count);

언어 레벨

ANSI

스레드세이프

설명

memmove() 함수는 srccount 바이트를 dest에 복사합니다. 이 함수는 src가 처음 임시 배열에 복사되는 것처럼 중첩될 수 있는 오브젝트 간 복사를 허용합니다.

리턴값

memmove() 함수는 dest에 대한 포인터를 리턴합니다.

이 예는 단어 "shiny"를 위치 target + 2에서 위치 target + 8에 복사합니다.
#include <string.h>
#include <stdio.h>
 
#define SIZE    21
 
char target[SIZE] = "a shiny white sphere";
 
int main( void )
{
  char * p = target + 8;  /* p points at the starting character
                          of the word we want to replace */
  char * source = target + 2; /* start of "shiny" */
 
  printf( "Before memmove, target is \"%s\"\n", target );
  memmove( p, source, 5 );
  printf( "After memmove, target becomes \"%s\"\n", target );
}
 
/*********************  Expected output:  ************************
 
Before memmove, target is "a shiny white sphere"
After memmove, target becomes "a shiny shiny sphere"
*/