memcpy, wmemcpy
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

memcpy, wmemcpy

Copies characters between buffers.

void *memcpy(
   void *dest,
   const void *src,
   size_t count 
wchar_t *wmemcpy(
   wchar_t *dest,
   const wchar_t *src,
   size_t count


New buffer.
Buffer to copy from.
Number of bytes to copy.

Return Value

The value of dest.


Copies count bytes of src to dest. If the source and destination overlap, the behavior of memcpy is undefined. Use memmove to handle overlapping regions.

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
memcpy <memory.h> or <string.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
wmemcpy <wchar.h> 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.


See memmove for a sample of how to use memcpy.

See Also

Buffer Manipulation Routines | _memccpy | memchr | memcmp | memmove | memset | strcpy | strncpy | Run-Time Routines and .NET Framework Equivalents

© 2015 Microsoft