Format
#include <string.h> /* also <memory.h> */ void *memcpy(void *dest, const void *src, size_t count);
Language Level: ANSI, XPG4, Extension
memcpy copies count bytes of src to dest.
The behavior is undefined if copying takes place between objects
that overlap. (The memmove function allows copying between
objects that may overlap.)
Return Value
memcpy returns a pointer to dest.
Example
This example copies the contents of source to target.
#include <string.h> #include <stdio.h>
#define MAX_LEN 80
char source[ MAX_LEN ] = "This is the source string"; char target[ MAX_LEN ] = "This is the target string";
int main(void)
{
printf( "Before memcpy, target is \"%s\"\n", target );
memcpy( target, source, sizeof(source));
printf( "After memcpy, target becomes \"%s\"\n", target );
return 0;
/************************************************************
The output should be:
Before memcpy, target is "This is the target string"
After memcpy, target becomes "This is the source string"
************************************************************/
}
memccpy -- Copy Bytes
memchr -- Search Buffer
memcmp -- Compare Buffers
memicmp -- Compare Bytes (Not 400 C)
memmove -- Copy Bytes
memset -- Set Bytes to Value
strcpy -- Copy Strings
<string.h>