#include <string.h>
void *memcpy(void *dest, const void * src, size_t n)
Parameters
dest − This is pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
src − This is pointer to the source of data to be copied, type-casted to a pointer of type void*.
n − This is the number of bytes to be copied.
#include <stdio.h>
#include <string.h>
int main () {
const char src[50] = "http://www.tutorialspoint.com";
char dest[50];
strcpy(dest,"Heloooo!!");
printf("Before memcpy dest = %s
", dest);
memcpy(dest, src, strlen(src)+1);
printf("After memcpy dest = %s
", dest);
return(0);
}
int dst[ARRAY_LENGTH];
memcpy( dst, src, sizeof(dst) ); // Good, sizeof(dst) returns sizeof(int) * ARRAY_LENGTH