size_type size() const;
size_type size() const noexcept;
1
2
3
4
5
6
7
8
9
10
// string::size
#include <iostream>
#include <string>
int main ()
{
std::string str ("Test string");
std::cout << "The size of str is " << str.size() << " characters.\n";
return 0;
}
The size of str is 11 characters