Modifying Operations
Strings have many operations to modify them. str.assign
assigns a new string to the string str
. With str.swap
you can swap two strings. To remove a character from a string use str.pop_back
or str.erase
. In contrary str.clear
or str.erase
deletes the whole string. To append new characters to a string use +=, std.append
or str.push_back
. You can use str.insert
to insert new characters or str.replace
to replace characters.
Methods | Description |
---|---|
str= str2 |
Assigns str2 to str . |
str.assign(...) |
Assigns to str a new string. |
str.swap(str2) |
Swaps str and str2 . |
str.pop_back() |
Removes the last character from str . |
str.erase(...) |
Removes characters from str . |
str.clear() |
Clears the str . |
str.append(...) |
Appends characters to str . |
...