.length()

tefyfernandez13 total contributions
Published Apr 4, 2022Updated Apr 10, 2023
Contribute to Docs
The .length()
method returns the length of the given string in terms of bytes. It functions exactly like the .size() method but follows a more intuitive terminology (i.e., “the length of a string” rather than “the size of a string”). However, both methods yield the same result.
Syntax
string.length();
The string
must be defined with std::string
prior to using with the .length()
method.
Codebyte Example
In the example below, .length()
is called on the snack
string:
All contributors
- tefyfernandez13 total contributions
- Christine_Yang269 total contributions
- garanews209 total contributions
- BrandonDusch580 total contributions
- KyraThompson67 total contributions
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.