关于 memcpy(),memcmp()

jndxhdu 2012-07-27 02:10:46
我看了一下资料,说是用到memcpy(),memcmp(),需要头文件<string.h>,但是我写了代码测试下,发现不需要头文件<string.h>也是可以的,这是为什么呢?
...全文
264 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
jndxhdu 2012-07-27
  • 打赏
  • 举报
回复
没有用写上去干嘛呢??[Quote=引用 11 楼 的回复:]

讨论这些有什么用,你在程序的时候肯定是写尽可能多的头文件库
[/Quote]
夏天__ 2012-07-27
  • 打赏
  • 举报
回复
讨论这些有什么用,你在程序的时候肯定是写尽可能多的头文件库
赵4老师 2012-07-27
  • 打赏
  • 举报
回复
IDE中在memcpy上点鼠标右键,选转到定义。
自信男孩 2012-07-27
  • 打赏
  • 举报
回复
嗯,那么加上-Wall参数了吗?如果加上该参数一般会有警告的。
jndxhdu 2012-07-27
  • 打赏
  • 举报
回复
在cygwin下编译完成
yht8708 2012-07-27
  • 打赏
  • 举报
回复
Required header
memcpy
<memory.h> or <string.h>

jndxhdu 2012-07-27
  • 打赏
  • 举报
回复
在cygwin下编译完成。
wyfwx 2012-07-27
  • 打赏
  • 举报
回复
memcpy
Copies characters between buffers.

void *memcpy( void *dest, const void *src, size_t count );

Routine Required Header Compatibility
memcpy <memory.h> or <string.h> ANSI, Win 95, Win NT


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

可能别的头文件里面包含了
jndxhdu 2012-07-27
  • 打赏
  • 举报
回复
代码是这样的

#include <stdio.h>

int main()
{
char *s="abc";
char a[4]={0};
memcpy(a,s,3);
printf("a=s?%d\n",memcmp(a,s,3));
printf("%s\n",a);
return 0;
}
wyfwx 2012-07-27
  • 打赏
  • 举报
回复
memcpy
Copies characters between buffers.

void *memcpy( void *dest, const void *src, size_t count );

Routine Required Header Compatibility
memcpy <memory.h> or <string.h> ANSI, Win 95, Win NT


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version


这是传世的最完整帮助文档。

估计是你别的头文件里面已经包含了
jndxhdu 2012-07-27
  • 打赏
  • 举报
回复
都没有,只有一个头文件<stdio.h>[Quote=引用 1 楼 的回复:]

可能包了<memory.h> or <string.h> or <windows.h>
[/Quote]
wfq0987 2012-07-27
  • 打赏
  • 举报
回复
可能包了<memory.h> or <string.h> or <windows.h>

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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