I have a function that removes all occurrences of a sub-string from a c++ string. But I want it to insert spaces before or after removing every sub-string. My Function if given below:
void removeSubstrs(string& s, string& p) {
string::size_type n = p.length();
for (string::size_type i = s.find(p);
i != string::npos;
i = s.find(p))
s.erase(i, n);
}
For example if I input "AZAZBLACKAZAZBERRYAZ", I want the output "BLACK BERRY"....