Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

C++ Help!! I have a string, and I want to remove the character and then use concatenation to replace it.

OpenStudy (anonymous):

say like the string is "He is eating an egg." The character of choice to remove is 'e'. So the result would be "H is ating an gg.". How to do this by using string concatenation to replace the character??

OpenStudy (anonymous):

not sure what you mean by string concatenation. concatenation means adding 2 things together, but you're removing things here. one way is loop over the string char by char. check if it's an 'e', replace with '' another way would be to use the stl ``` #include <algorithm> #include <string> ... std::replace( s.begin(), s.end(), 'x', 'y'); // replace all 'x' to 'y' ```

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!