NeDark
NeDark

Reputation: 1294

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

Upvotes: 4

Views: 7683

Answers (2)

Fred Larson
Fred Larson

Reputation: 62053

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

Upvotes: 4

wkl
wkl

Reputation: 79893

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

Upvotes: 8

Related Questions