C语言 编写程序实现内存拷贝,不考虑内存重叠。不允许调用memcpy函数

来源:互联网 发布:淘宝亲子装商城 编辑:程序博客网 时间:2024/04/29 16:17

编写程序实现内存拷贝,不考虑内存重叠。不允许调用memcpy函数


#include <stdio.h>#include <string.h>void * my_memcpy(void *dst,void const *src, int count){while(count--){*((char*)(dst+count)) = *((char*)(src+count));}return dst;}int main(){char *p = "abcdefghijklmn";char q[20];my_memcpy(q,p,strlen(p)+1);printf("%s\n",q);return 0;}

运行结果截图:


0 0