c++ remove quotes from string code example
Example 1: removing a character from a string in c++
#include<iostream>
#include<algorithm>
using namespace std;
main() {
string my_str = "ABAABACCABA";
cout << "Initial string: " << my_str << endl;
my_str.erase(remove(my_str.begin(), my_str.end(), 'A'), my_str.end()); //remove A from string
cout << "Final string: " << my_str;
}
Example 2: c++ remove space from string
static std::string removeSpaces(std::string str)
{
str.erase(remove(str.begin(), str.end(), ' '), str.end());
return str;
}