Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <string.h>
void *memmove(void *dest, const void *src, size_t count);
Copies count bytes from the object pointed to by src to the object pointed to by dest. The memmove() function allows copying between possibly overlapping objects as if the count bytes of the object pointed to by src must first copied into a temporary array before being copied to the object pointed to by dest.
memmove() returns the value of dest.
⁄* CELEBM14
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 );
}
Before memmove, target is "a shiny white sphere"
After memmove, target becomes "a shiny shiny sphere"