memmove() — Move buffer

Standards

Standards / Extensions C or C++ Dependencies

ISO C
XPG4
XPG4.2
C99
Single UNIX Specification, Version 3

both  

Format

#include <string.h>

void *memmove(void *dest, const void *src, size_t count);

General description

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.

Returned value

memmove() returns the value of dest.

Example

CELEBM14
⁄* 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 );
}
Output
Before memmove, target is "a shiny white sphere"
After memmove, target becomes "a shiny shiny sphere"

Related information