C++ String size() 函数
示例
获取字符串的长度:
string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout << "The length of the txt
string is: " << txt.size();
亲自试一试 »
定义和用法
size() 函数返回字符串的长度。
注意: 您也可以使用 length() 函数来获取字符串的长度。
这只是 size() 的别名,它们的行为相同。
语法
string.size();
参数
None.
技术细节
| 返回值: | 字符串中的字符数。 |
|---|
相关页面
阅读我们的String字符串教程,了解更多关于字符串的知识。

