Export (0) Print
Expand All
Expand Minimize

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
);

Parameters

dest
Destination object.
src
Source object.
count
Number of bytes of characters to copy.

Return Value

The value of dest.

Remarks

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.

Requirements

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.

Libraries

All versions of the C run-time libraries.

Example

// 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 );
}

Output

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

Show:
© 2014 Microsoft