std::basic_string::max_size in C++
Last Updated :
12 Jun, 2019
Improve
std::basic_string::max_size is used to compute the maximum number of elements the string is able to hold due to system or library implementation limitations.
CPP
Output:
size_type max_size() const; Parameters : None Return value : Maximum number of characters Exceptions : None
// CPP program to compute the limit of a string
// using max_size
#include <iostream>
#include <string>
int main()
{
std::string str;
// Calling max_size()
std::cout << "Maximum size of a string is " << str.max_size() << std :: endl;
}
Maximum size of a string is 4294967294Note : The maximum size can depend on the compiler and system.
Article Tags :