00问答网
所有问题
C++有测字符串长度的函数吗
.length 是Java用的吧。
举报该问题
推荐答案 推荐于2017-10-02
string str="welcome to chaina!";
int m1=str.size();//求字符串长度或者下面的
int m2=str.length(); //同上面size功能一样,都是求字符串长度的
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://00.wendadaohang.com/zd/eDZTDnr0.html
其他回答
第1个回答 2008-07-23
string istr("abcd");
cout << istr.length() << endl;
这样就可以了~~~java好多东西不就是学的C++的吗?本回答被提问者采纳
第2个回答 2008-07-23
strlen
第3个回答 2008-07-23
.length
相似回答
c++
中如何
测量
一个
字符串的长度
?
答:
c++
<string> 里面的头文件里面就有了strlen
函数
就可以了吧用string定义数据 include<iostream> #include<string> using namespace std;main(){
string s
;cin>>s;cout<<s;cout<<strlen(s);}应该就可以了
怎么用
c++
统计
字符串的长度
? 前提是不知道字符串的长度
答:
C++
?推荐使用
string
类来存储
字符串
。例子:include <iostream> include <string> //此行一定要有 using namespace std;int main (void){ string a;cin>>a;cout<<a<<endl;return 0;} 输入abc输出abc 很方便 它也可以当作数组使用,如cout<<a[1]<<endl就是输出b一个字符。
测长度
是其中的成...
C++
中用什么关键字可以得出
字符串的长度
答:
C中(当然
C++
也可以用)用 char [] 数组来表示字符串,在string.h (或cstring)中
有函数
strlen可以求
字符串长度
。比如char a[10]="12345\0",那么strlen(a)就表示a的长度,为5.值得注意的有两点:① char[] 数组的结尾都是以 '\0' (NULL,表示空)来作为结束标志的,在屏幕上是不可见的。strle...
输入一个
字符串
(最长100个字符)请编写专门
函数
,统计输入的字符串中有...
答:
string
str;cout << "Enter a string: ";getline(cin, str);cout << "The string has " << countChar(str) << " characters." << endl;return 0;} 在这段代码中,我们定义了一个
函数
countChar,用于统计字符串中有多少个字符。我们使用了 string 库中的 length 函数来计算
字符串的长度
...
大家正在搜
测字符串长度的函数
调用函数测字符串的长度
测字符串长度函数strlen
c语言测字符串长度函数
strlen函数可以测数字长度吗
返回字符串长度的函数
计算字符串长度的函数
求字符串长度的库函数是什么
如何测字符串的长度
相关问题
c++字符串长度函数
求字符串长度函数 C++
c++中如何测量一个字符串的长度?
C++字符串有效长度的问题
c++计算字符串长度
C++ 获取字符串长度的函数是什么?
关于c++中求字符串长度的函数strlen的小问题
c++中怎么获得字符串的长度