String Max Size Function

C++ String max_size

This function returns the maximum length the string can reach due to known system.

Syntax

Consider a string str. Syntax would be:

Example

str.max_size();

Parameters

It does not contain any parameter.

Return value

This function returns the maximum length that string can reach.

Example 1

Let's see the simple example.

Example

#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;
}

Input Required

This code uses input(). Please provide values below: