You are here : cpp0memmove

memmove() - 0

The C library function void *memmove(void *str1, const void *str2, size_t n) copies n characters from str2 to str1, but for overlapping memory blocks, memmove() is a safer approach than memcpy().


Syntax

void *memmove(void *str1, const void *str2, size_t n)


Example

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

int main ()
{
   const char dest[] = "oldstring";
   const char src[]  = "newstring";

   printf("Before memmove dest = %s, src = %s\n", dest, src);
   memmove(dest, src, 9);
   printf("After memmove dest = %s, src = %s\n", dest, src);

   return(0);
}


Output / Return Value

Before memmove dest = oldstring, src = newstring
After memmove dest = newstring, src = newstring


Limitations


Alternatives / See Also


Reference