LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 688|回复: 2

看不懂这个库函数,请大家帮我解释一下!

[复制链接]
发表于 2004-3-28 20:42:49 | 显示全部楼层 |阅读模式

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. int main( void )
  5. {
  6.     char buffer[80];
  7.     strcpy( buffer, "World");
  8.     memmove( buffer+1, buffer, 79 );
  9.     printf ("%s\n", buffer);
  10.     return EXIT_SUCCESS;
  11. }
  12. # ./a.out
  13. WWorld
复制代码

算法看不懂,请大家解释,,谢谢!
发表于 2004-3-28 21:03:06 | 显示全部楼层
把memmove搞懂就行了,这个程序就是为了演示memmove和memcpy的不同,
memmove可以很好的处理源区域和目标区域有重叠的情况
发表于 2004-4-19 14:49:18 | 显示全部楼层
将buffer内的数据向移一个字节
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表