str.size是一个字符串的成员函数,用于返回字符串的长度,即字符串中字符的数量。它的语法如下:

str.size()

其中,str是要计算长度的字符串。

示例:

#include <iostream>
#include <string>

int main() {
    std::string str = "Hello World";
    std::cout << "The length of str is: " << str.size() << std::endl;
    return 0;
}

输出结果为:

The length of str is: 11
strsize的用法

原文地址: https://www.cveoy.top/t/topic/eqWt 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录