#include <stdio.h> #include <stdlib.h> #include <assert.h> void *my_memcpy(void *p1,const void *p2, size_t count) { assert(p1); assert(p2); char *dest = (char*)p1; char *src = (char*)p2; while (count--) { *dest++ = *src++; } return p1; } int main() { float arr1[160]; float arr2[10] = {1.0,2.0}; size_t count = sizeof(arr2)*(sizeof(arr2) / sizeof(arr2[0])); float *ret = my_memcpy(arr1, arr2, count); int i = 0; for (i = 0; i < 10; i++) { printf("%f ", *(ret+i)); } system("pause"); return 0; }
【C语言】【面试题】【笔试题】模拟实现数据库中memcpy函数
原文地址:http://10740329.blog.51cto.com/10730329/1714519