memcpy和strcpy
来源:互联网 发布:淘宝金牌卖家条件 编辑:程序博客网 时间:2024/06/10 22:55
http://blog.csdn.net/xiaobo620/article/details/7488827
void *mymemcpy(void *dst,const void *src,size_t num)//效率优先
{
assert((dst!=NULL)&&(src!=NULL));
int wordnum = num/4;//计算有多少个32位,按4字节拷贝
int slice = num%4;//剩余的按字节拷贝
int * pintsrc = (int *)src;
int * pintdst = (int *)dst;
while(wordnum--)*pintdst++ = *pintsrc++;
while (slice--)*((char *)pintdst++) =*((char *)pintsrc++);
return dst;
}
http://blog.csdn.net/yahohi/article/details/7927806 内存重叠问题解决
void *memmove(void *dest, const void *source, size_t count)
{
assert((NULL != dest) && (NULL != source));
char *tmp_source, *tmp_dest;
tmp_source = (char *)source;
tmp_dest = (char *)dest;
if((dest + count<source) || (source + count) <dest))
{// 如果没有重叠区域
while(count--)
*tmp_dest++ = *tmp_source++;
}
else
{ //如果有重叠(反向拷贝)
tmp_source += count - 1;
tmp_dest += count - 1;
while(count--)
*--tmp_dest = *--tmp;
}
return dest;
}
0 0
- strcpy和memcpy
- strcpy和Memcpy。
- strcpy和memcpy
- strcpy和memcpy
- memset ,memcpy 和strcpy
- strcpy和memcpy
- strcpy和memcpy区别
- Strcpy 和 memcpy 实现
- strcpy、strncpy 和 memcpy
- strcpy和memcpy 区别
- strcpy和memcpy区别
- strcpy和memcpy区别
- memcpy和strcpy
- memcpy 和 strcpy()
- strcpy和memcpy
- strcpy和memcpy区别
- memcpy和strcpy
- strcpy和memcpy
- 毕业这三年 (下)
- 编译arm版本的QT遇到的问题
- iOS 8最佳适配——被点赞的百度输入法
- phonegap开发--基于iscroll4实现下拉刷新等问题解析
- 阿里开放数据处理服务(ODPS)-余波
- memcpy和strcpy
- LEADTOOLS使用教程:图像数据格式的更改
- 时间函数整理
- Android Intent Flag的介绍
- Ubuntu上挂载ntfs硬盘,并开机启动svn服务器
- LEADTOOLS使用教程:图像的几何变换
- Python学习笔记5:函数参数详解
- SQL中where 1=1的用法
- The Last Time For Yourself!