标签:memcpy
//不用库函数实现memcpy #include <stdio.h> #include <assert.h> void * my_memcpy ( void *dst, void const *src, int count ) { void * ret = dst; assert( ( dst != NULL ) && ( src != NULL )); while( count-- ) { *( ( char * )dst ) = *( ( char * )src ); ( ( char * )dst )++; ( ( char * )src )++; } *( ( char * )dst ) = '\0'; return ret; } int main() { char dst[] = "shiqinianchan"; char *src = "dandanwa"; my_memcpy( dst, src, 8); printf("内存拷贝后的结果是:%s\n",dst); return 0; }
标签:memcpy
原文地址:http://blog.csdn.net/zhaoyaqian552/article/details/44752229