Syntax
#include <string.h> /* also in <memory.h> */ void *memmove(void *dest, const void *src, size_t count);Description
memmove copies count bytes of src to dest. memmove allows copying between objects that may overlap as if src is first copied into a temporary array.
memmove returns a pointer to dest.
This example copies the word shiny from position target + 2 to position 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);
return 0;
/****************************************************************************
The output should be:
Before memmove, target is "a shiny white sphere"
After memmove, target becomes "a shiny shiny sphere"
****************************************************************************/
}
Related Information