Delete from string

How can I remove something from a string? Example: “tree” “tee”

13th Feb 2020, 8:27 PM
1 Answer
+ 3
If you have the option to work with C++ strings, calling the erase() method would be sufficient, the class will handle the rest for you: https://en.cppreference.com/w/cpp/string/basic_string/erase The class also provides various methods for finding certain characters in a string, e.g. find(), which return the index of the character, which you can then use as an argument for erase(). You can find all the necessary documentation with examples here: https://en.cppreference.com/w/cpp/string/basic_string
13th Feb 2020, 9:20 PM
Shadow - avatar