You are on page 1of 1

C++ String Library Function

- `length()` - returns the length of the string


- `size()` - same as `length()`, returns the length of the string
- `empty()` - returns true if the string is empty, false otherwise
- `clear()` - clears the contents of the string
- `append(str)` - appends the string `str` to the end of the current string
- `insert(pos, str)` - inserts the string `str` at the position `pos` in the
current string
- `erase(pos, len)` - erases `len` characters starting from the position `pos`
in the current string
- `replace(pos, len, str)` - replaces `len` characters starting from the
position `pos` with the string `str`
- `substr(pos, len)` - returns a substring of length `len` starting from the
position `pos`
- `find(str)` - returns the position of the first occurrence of the string `str`
in the current string, or `string::npos` if not found
- `rfind(str)` - returns the position of the last occurrence of the string `str`
in the current string, or `string::npos` if not found

You might also like