Search code examples
c++stringsizestorage

How many characters can fit in a C++ string?


I need to store in a variable, kilobytes or even megabytes of plain text, so I want to know how many characters can fit in a standard string (aka std::string plus string library).


Solution

  • std::string has the member function max_size() which returns the maximum length of a std::string in that implementation.