memmove, wmemmove
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

memmove, wmemmove

Moves one buffer to another.

void *memmove(
   void *dest,
   const void *src,
   size_t count 
wchar_t *wmemmove(
   wchar_t *dest,
   const wchar_t *src,
   size_t count


Destination object.
Source object.
Number of bytes of characters to copy.

Return Value

The value of dest.


Copies count bytes of characters from src to dest. If some regions of the source area and the destination overlap, memmove ensures that the original source bytes in the overlapping region are copied before being overwritten.

Security Note   Make sure that the destination buffer is the same size or larger than the source buffer. For more information, see Avoiding Buffer Overruns.


Routine Required header Compatibility
memmove <string.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
wmemmove <wchar.t> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_memcpy.c
/* Illustrate overlapping copy: memmove
 * always handles it correctly; memcpy may handle
 * it correctly.

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

char str1[7] = "aabbcc";

int main( void )
   printf( "The string: %s\n", str1 );
   memcpy( str1 + 2, str1, 4 );
   printf( "New string: %s\n", str1 );

   strcpy( str1, "aabbcc" );   // reset string

   printf( "The string: %s\n", str1 );
   memmove( str1 + 2, str1, 4 );
   printf( "New string: %s\n", str1 );


The string: aabbcc
New string: aaaabb
The string: aabbcc
New string: aaaabb

See Also

Buffer Manipulation Routines | _memccpy | memcpy | strcpy | strncpy | Run-Time Routines and .NET Framework Equivalents

© 2015 Microsoft