string max_size() in C++

max_size():It returns the size() of the largest possible string.

This function is available in the below file.

File: basic_string.h

Parameter: No parameters are required for this function.

Syntax:

str.max_size()

For Example:

str = "abc"

str.max_size()  = > It returns 9223372036854775807

(maximum size of the string possible)

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string str = "abc";

    cout << str.max_size() << "\n";
  
    return 0;
}


No comments:

Post a Comment