Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 959
NeDark Avatar asked Dec 17 '22 19:12

NeDark


2 Answers

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

like image 56
逆さま Avatar answered Dec 20 '22 21:12

逆さま


It depends on your implementation. Try calling std::string::max_size() and find out.

like image 31
Fred Larson Avatar answered Dec 20 '22 21:12

Fred Larson