strcpy的实现
来源:互联网 发布:windows安全确认证书 编辑:程序博客网 时间:2024/05/16 05:52
要考虑内存重叠
char * strcpy(char *dst,const char *src){ assert(dst != NULL && src != NULL); char *ret = dst; my_memcpy(dst, src, strlen(src)+1); return ret;}char *my_memcpy(char *dst, const char* src, int cnt){ assert(dst != NULL && src != NULL); char *ret = dst; if (dst >= src && dst <= src+cnt-1) //内存重叠,从高地址开始复制 { dst = dst+cnt-1; src = src+cnt-1; while (cnt--) *dst-- = *src--; } else //正常情况,从低地址开始复制 { while (cnt--) *dst++ = *src++; } return ret;}
0 0
- strcpy()库函数的实现
- strcpy函数的实现
- strcpy的实现
- 面试:strcpy的实现
- strcpy()的实现
- strcpy的实现
- strcpy的实现
- strcpy 的实现
- strcpy的实现代码
- strcpy的严格实现
- strcpy的实现代码
- strcpy函数的实现
- strcpy()的简洁实现
- strcpy函数的实现
- strcpy函数的实现
- strcpy的实现
- strcpy的实现
- strcpy函数的实现
- 解密亚洲一号巨型仓储管理
- XCode中创建pch文件
- CSS3技术初探
- 欢迎使用CSDN-markdown编辑器
- Spring生态环境
- strcpy的实现
- 龙卷风--邓紫棋
- java Map的使用
- NYOJ-49
- ECMAScript6技术初探
- POJ 2253 Frogger
- 交换就修改telnet密码
- c/c++大纲
- MySQL dump步骤