gpt4 book ai didi

c++ - 计算字符串 C++ 中字符数的标准函数

转载 作者:行者123 更新时间:2023-11-28 07:20:32 25 4
gpt4 key购买 nike

是否有像 size() 或 length() 这样的标准函数来计算字符串中的字符数。下面给出同一个词的 5 和 6 :

#include <iostream>
using namespace std;
int main(){
string s="Ecole";
cout<<s.size()<<"\n";
}

#include <iostream>
using namespace std;
int main(){
string s="école";
cout<<s.size()<<"\n";
}

谢谢。

最佳答案

使用:

wstring

代替:

string

关于c++ - 计算字符串 C++ 中字符数的标准函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19547154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com