C++ 字串庫 - max_size



描述

它返回字串可以達到的最大長度。

宣告

以下是 std::string::max_size 的宣告。

size_t max_size() const;

C++11

size_t max_size() const noexcept;

引數

返回值

它返回字串可以達到的最大長度。

異常

從不丟擲任何異常。

示例

以下是如何使用 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
string.htm
廣告
© . All rights reserved.