Published Apr 4, 2022Updated Apr 10, 2023
Contribute to Docs
.size() method returns the size of a given string in terms of bytes. It functions just like the
.length() method, but
.size() is there to follow the consistency of other standard library containers (e.g., maps and vectors).
string must be defined with
std::string prior to using with the
In the example below,
.size() is called on the
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
Computer ScienceLooking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Includes 6 Courses
With Professional Certification