无涯教程-进程 - int max_size()函数

67 阅读1分钟

此函数返回由于已知系统而导致的字符串可以达到的最大长度。

max_size - 语法

str.max_size();

max_size - 返回值

此函数返回字符串可以达到的最大长度。

max_size - 例子1

让我们看一个简单的例子。

#include<iostream>
using namespace std;
int main()
{
string str = "Hello world";
cout<<"String is :" <<str<<
;
cout<<"Maximum size of the string is :"<<str.max_size();
return 0;
} 

参考链接

www.learnfk.com/c++/cpp-str…