参考: https://www.tutorialspoint.com/c_standard_library/c_function_memcpy.htm
声明:
void *memcpy(void *str1, const void *str2, size_t n) /*1. str1 − This is pointer to the destination array
where the content is to be copied, type-casted to a pointer of type void*. *2.This is pointer to the source of data to be copied,
type-casted to a pointer of type void* 3. n − This is the number of bytes to be copied. */
Example:
#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); }
Output:
/*Before memcpy dest = Heloooo!! After memcpy dest = http://www.tutorialspoint.com */