how to erase a specific string in c++ code example
Example 1: delete one specific character in string C++
#include <algorithm>
str.erase(std::remove(str.begin(), str.end(), 'a'), str.end());
Example 2: string erase character c++
#include <iostream>
#include <algorithm>
#include <string>
int main()
{
std::string s = "This is an example";
std::cout << s << '\n';
s.erase(0, 5);
std::cout << s << '\n';
s.erase(std::find(s.begin(), s.end(), ' '));
std::cout << s << '\n';
s.erase(s.find(' '));
std::cout << s << '\n';
}