【请教】用memmove函数如何实现交换数组中的元素呢?

wangfan88 2008-03-24 09:53:53
【请教】用memmove函数如何实现交换数组中的元素呢?关于memmove的参数使用,一直不太明白,谢谢大家了o(∩_∩)o...
memmove(a+i,&x+1,1)。。这样恐怕不行吧。。。该怎样呢。。。希望高人指点!
...全文
132 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ryfdizuo 2008-03-24
  • 打赏
  • 举报
回复
函数:void * memmove ( void * destination, const void * source, size_t num );
ryfdizuo 2008-03-24
  • 打赏
  • 举报
回复
Parameters
destination
Pointer to the destination array where the content is to be copied,
type-casted to a pointer of type void*.
source
Pointer to the source of data to be copied, type-casted to a pointer of type const void*.
num
Number of bytes to copy.

Return Value
destination is returned.

Example
/* memmove example */
#include <stdio.h>
#include <string.h>

int main ()
{
char str[] = "memmove can be very useful......";
memmove (str+20,str+15,11);
puts (str);
return 0;
}
Output:
memmove can be very very useful.

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧