76 412
Assignments Done
Successfully Done
In May 2019

Answer to Question #40757 in C++ for mpho

Question #40757
returns a string that has all occurrences of a given character
Expert's answer
#include <cstring>
#include <iostream>
using namespace std;
string removeAll (string s, char c)
for (int i = 0; i < s.length(); i++)
if (s[i] == c)
s.erase(s.begin() + i--);
return s;
int main() {
string s = "I have a doggie ttttttttttt";
char c = 't';
cout << removeAll(s, c);
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions