文字列::容量の文字列::サイズstring ::長文字列:: MAX_SIZE

size_tの容量()constはnoexcept。

書式#include <iostreamの>
の#include <文字列>

名前空間stdを使用。

INTメイン()
{
文字列S1( "こんにちは");
COUT << "容量:" << s1.capacity()<< ENDL; // 15
COUT << "長さ" << s1.length()<< ENDL; // 5
COUT << "MAX_SIZE:" < <s1.max_size()<< ENDL; // 9223372036854775807(63个1)
COUT << "サイズ" << s1.size()<< ENDL; // 5
リターン0。
}

おすすめ

転載: www.cnblogs.com/xpylovely/p/12083303.html