由於已知係統,此函數返回字符串可以達到的最大長度。
用法
考慮一個字符串 str。語法是:
str.max_size();
參數
它不包含任何參數。
返回值
此函數返回字符串可以達到的最大長度。
例子1
讓我們看一個簡單的例子。
#include<iostream>
using namespace std;
int main()
{
string str = "Hello world";
cout<<"String is:" <<str<<'\n';
cout<<"Maximum size of the string is:"<<str.max_size();
return 0;
}
相關用法
- C++ String swap()用法及代碼示例
- C++ String back()用法及代碼示例
- C++ String append()用法及代碼示例
- C++ String Assign()用法及代碼示例
- C++ String begin()用法及代碼示例
- C++ String size()用法及代碼示例
- C++ String resize()用法及代碼示例
- C++ String Find()用法及代碼示例
- C++ String crend()用法及代碼示例
- C++ String compare()用法及代碼示例
- C++ String empty()用法及代碼示例
- C++ String replace()用法及代碼示例
- C++ String at()用法及代碼示例
- C++ String insert()用法及代碼示例
- C++ String clear()用法及代碼示例
- C++ String Data()用法及代碼示例
- C++ String cend()用法及代碼示例
- C++ String pop_back()用法及代碼示例
- C++ String find_first_not_of()用法及代碼示例
- C++ String find_last_of()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ String max_size()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。