The function memcpy( ) is defined in the header file <string.h>. The prototype of the function memcpy( ) is as follows.
void * memcpy(void* destination,const void* source,size_t num);
The function memcpy( ) copies the values of num bytes from the location pointed by source directly to the memory block pointed by destination.
#include<stdio.h>
#include <string.h>
int main()
{
int abc[ ] = {111, 222, 333};
int copy[3],i;
memcpy(copy, abc, sizeof(int)*3);
abc[0] = 444;
printf("\nArray abc is :");
for(i=0;i<3;i++)
{
printf("\n%d",abc[i]);
}
printf("\nArray copy is :");
for(i=0;i<3;i++)
{
printf("\n%d",copy[i]);
}
return 0;
}
Click here to download the C Program.