memmove() function in C/C++

CC++Server Side Programming

The function memmove() is used to move the whole memory block from one position to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language.

Here is the syntax of memmove() in C language,

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


dest_str − Pointer to the destination array.

src_str − Pointer to the source array.

number − The number of bytes to be copied from source to destination.

Here is an example of memmove() in C language,


 Live Demo

#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

In the above program, two char type arrays are initialized and memmove() function is copying the source string ‘b’ to the destination string ‘a’.

char a[] = "Firststring";
const char b[] = "Secondstring";
memmove(a, b, 9);
Published on 05-Nov-2018 11:09:00