String class

length()

String::length, length, String.length

Returns the length of the String, in characters. (Note that this doesn't include a trailing null character.)

// SYNTAX
string.length()

// PROTOTYPE
inline unsigned int length(void) const;

Parameters:

  • string: a variable of type String

Returns: The length of the String in characters.

The length() function is fast and is constant for any length of string, Ο(1). You can efficiently use length() to determine if a string is empty: length() == 0.