c++ function to calculate length of string code example Example: length of string in c++ str.length();