标签:c语言:模拟实现memcpy 函数库函数的实现 面试题1.模拟实现
#define _CRT_SECURE_NO_WARNINGS 1 #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; char *ret = dest; while (count--) { *dest = *src; src++; dest++; } return ret; } int main() { float arr1[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 }; float arr2[10]; int i = 0; int len = sizeof(arr1); float *ret = my_memcpy(arr2, arr1,len ); for (i = 0; i < 9; i++) { printf("%f ", *(ret + i)); } system("pause"); return 0; }
标签:c语言:模拟实现memcpy 函数库函数的实现 面试题1.模拟实现
原文地址:http://10740184.blog.51cto.com/10730184/1714511