//模拟实现memcpy库函数 #include <stdio.h> #include <string.h> void * my_memcpy(void * dst, const void * src, int count) { void *ret = dst; while (count--) { *(char *)dst = *(char *)src; dst=(char *)dst+1; src=(char *)src+1; } return ret; } int main() { char p[] = "abcdef"; //char q[] = "abcdef"; char *a = "fghj"; my_memcpy(p, a, 2); //memcpy(q, a, 2); printf("%s\n", p); //printf("%s\n", q); return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-05 19:57:12