C++ string Library
C++ string Functions
The <string>
library has many functions that allow you to perform tasks on strings.
A list of popular string functions can be found in the table below.
Function | Description |
---|---|
at() | Returns an indexed character from a string |
length() | Returns the length of a string |
size() | Alias of length(). Returns the length of a string |
max_size() | Returns the maximum length of a string |
empty() | Check whether a string is empty or not |
append() | Append a string (or a part of a string) to another string |
substr() | Returns a part of a string from a start index (position) and length |
find() | Returns the index (position) of the first occurrence of a string or character |
rfind() | Returns the index (position) of the last occurrence of a string or character |
replace() | Replaces a part of a string with another string |
insert() | Inserts a string at a specified index (position) |
erase() | Removes characters from a string |
compare() | Compares two strings |