#include <stdio.h>
#include <stdlib.h>
void *mymemcpy(void *str, const void *dst, size_t count) {
void *ret = str;
while (--count) {
*(char*)str = *(char*)dst;
str = (char*)str + 1;
dst = (char*)dst + 1;
}
return ret;
}
int main() {
char str[] = "abcdefghigklmn";
char dst[] = "hello world";
void *ret = mymemcpy(str, dst, 9);
printf("%s\n", (char*)ret);
system("pause");
return 0;
}
模拟实现memcpy
最新推荐文章于 2022-04-03 12:09:26 发布