string::size |
public member function |
Return length of string
Returns a count of the number of characters in the string.
string::length is an alias of string::size, returning both the exact same value.
Parameters
none
Return Value
The number of characters that conform the string's content.
size_t is an unsigned integral type.
Example
// string::size
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Test string");
cout << "The size of str is " << str.size() << " characters.\n";
return 0;
}
|
Output:
The size of str is 11 characters.
|
Basic template member declaration
( basic_string<charT,traits,Allocator> )
typedef typename Allocator::size_type size_type;
size_type size() const;
|
See also