length

Syntax:

    #include <string>
    size_type length() const;

The length() function returns the number of elements in the current string, performing the same role as the size() function.

If testing whether a string is empty or not, use empty() since it doesn't need to count beyond the first character in the string.

Related Topics: capacity, empty, max_size, resize, size