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

C / C ++The memmove() function in

This functionmemmove()used to move an entire storage block from one location to another. One is the source, and the other is a pointer pointing to the destination. This is declared in the 'string.h' header file using C language.

Thismemmove()C language syntax

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

here,

dest_str-pointer to the destination array.

src_str-pointer to the source array.

number-bytes, from source to destination.

Thismemmove()C Language Example

Example

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

Output result

New arrays: SecondstrngSecondstring

In the above program, two char type arrays are initialized,memmove()The function copies the source string 'b' to the destination string 'a'.

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