max_size
描述 (Description)
它返回字符串可以达到的最大长度。
声明 (Declaration)
以下是std :: string :: max_size的声明。
size_t max_size() const;
C++11
size_t max_size() const noexcept;
参数 (Parameters)
没有
返回值 (Return Value)
它返回字符串可以达到的最大长度。
异常 (Exceptions)
永远不要抛出任何例外
例子 (Example)
在下面的示例中为std :: string :: max_size。
#include <iostream>
#include <string>
int main () {
std::string str ("Sairamkrishna");
std::cout << "max_size: " << str.max_size() << "\n";
return 0;
}
样本输出应该是这样的 -
max_size: 4611686018427387897