Delete from string | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Delete from string

How can I remove something from a string? Example: ā€œtreeā€ ā€œteeā€

13th Feb 2020, 8:27 PM
Christian0972
1 Resposta
+ 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
Shadow - avatar