strlen 在那个头文件

budetcbc 2008-10-15 11:19:32
在c中可以找到strlen这个函数
可是在vc c++ strlen提示没有,
是不是没有这个函数的?
...全文
17637 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
crackle 2009-03-30
  • 打赏
  • 举报
回复 3
我晕,这个问题怎么这么多人会回答在 #include <string.h>中呢?
正确的是在 #include<cstring>中
zhangwei0826 2008-10-25
  • 打赏
  • 举报
回复
#include<string.h>中
e_sharp 2008-10-18
  • 打赏
  • 举报
回复
#include <string.h>
vbcpascal 2008-10-18
  • 打赏
  • 举报
回复
#include<cstring>
mazuhui 2008-10-17
  • 打赏
  • 举报
回复
#include <cstring>
cxxer 2008-10-17
  • 打赏
  • 举报
回复 1
#include <cstring>  //standard C++
#include <string.h> // ANSI C
陪你在路上 2008-10-16
  • 打赏
  • 举报
回复
新来的 学习了
sniper08 2008-10-16
  • 打赏
  • 举报
回复
标准C++
#include<iostream>
#include<cstring>
using namespace std;
或者
#include<iostream.h>
#include<string.h>

注意:string.h和cstring是C头文件
string是标准C++头文件,加入后,可以使用string类
ogiso_pest 2008-10-16
  • 打赏
  • 举报
回复
原型:extern int strlen(char *s);

用法:#include <string.h>

功能:计算字符串s的长度

说明:返回s的长度,不包括结束符NULL。

举例:


// strlen.c

#include <syslib.h>
#include <string.h>

main()
{
char *s="Golden Global View";

clrscr();

printf("%s has %d chars",s,strlen(s));

getchar();
return 0;
}

相关函数:无

lancelotviv 2008-10-16
  • 打赏
  • 举报
回复
当使用<iostream.h>时,相当于在c中调用库函数,使用的是全局命名空间,也就是早期的c++实现;
当使用<iostream>的时候,该头文件没有定义全局命名空间,必须使用namespace std;
比较两段代码:

#include <iostream.h>

int main()
{
cout<<"Hello, world!"<<endl;
return 0;
}


#include <iostream>

using namespace std;

int main()
{
cout<<"Hello, world!"<<endl;
return 0;
}
Dan_M 2008-10-16
  • 打赏
  • 举报
回复
strlen
<string.h>
ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003
budetcbc 2008-10-16
  • 打赏
  • 举报
回复
using namespace std;

这句话有什么作用的?
shiyi820509 2008-10-15
  • 打赏
  • 举报
回复
string.h
devil_zuiai 2008-10-15
  • 打赏
  • 举报
回复
在string.h里面吧。

c++中一般这样定义
#include <iostream>
#include <string>
using namespace std;
scengion 2008-10-15
  • 打赏
  • 举报
回复
string.h
冻结 2008-10-15
  • 打赏
  • 举报
回复
#include<string>
idea_yuye 2008-10-15
  • 打赏
  • 举报
回复
那里有函数库下载啊?
zzhzhua 2008-10-15
  • 打赏
  • 举报
回复
都对,可以下载个函数库什么的,以后用着也方便。
prx177705188 2008-10-15
  • 打赏
  • 举报
回复
学习
freash 2008-10-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 devil_zuiai 的回复:]
在string.h里面吧。

c++中一般这样定义
#include <iostream>
#include <string>
using namespace std;
[/Quote]

接分,前面的都对,呵呵
加载更多回复(2)

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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