English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C / C ++의 memmove() 함수

이 기능memmove()전체 저장 블록을 하나의 위치에서 다른 위치로 이동시키기 위해 사용됩니다. 하나는 원본이고, 다른 하나는 목적지를 가리키는 포인터입니다. 이는 'string.h' 헤더 파일에서 C 언어로 선언되었습니다.

이것은memmove()C 언어의 문법

void *memmove(void *dest_str, const void *src_str, size_t number)

여기서

dest_str-목적 배열을 가리키는 포인터

src_str-원본 배열을 가리키는 포인터

-의 바이트 수를 원본에서 목적지로 복사합니다。

이것은memmove()C 언어의 예제

예제

#include <stdio.h>
#include <string.h>
int main () {
   char a[] = "Firststring";
   const char b[] = "Secondstring";
   memmove(a, b, 9);
   printf("New arrays : %s\t%s", a, b);
   return 0;
}

출력 결과

New arrays : SecondstrngSecondstring

위 프로그램에서 두 개의 char 타입의 배열이 초기화됩니다。memmove()함수는 원본 문자열 'b'를 목적 문자열 'a'에 복사합니다。

char a[] = "Firststring";
const char b[] = "Secondstring";
memmove(a, b, 9);