cpp
#include <stdio.h>
#include <assert.h>
void* my_memcpy(void* dest, const void* ser, size_t num)
{
assert(dest && ser);
void* ret = dest;
while (num--)//
{
*(char*)dest = *(char*)ser;
dest = (char*)dest + 1;
ser = (char*)ser + 1;
}
return ret;
}
int main()
{
int arr1[] = { 1,2,3,4,5,6,7 };
int arr2[10] = {0};
my_memcpy(arr2, arr1, 4);
return 0;
}
图片解析说明