c++ string: is there good way to replace a char inside a string -


I want to change all the occurrences of 'string to ^', but I have seen the string. Replace is not the right function for me, do I have to write my own? It's boring.

You can & lt; Algorithm & gt; You can use String :: to & lt; String & gt;

Sample code

  #include & lt; Iostream & gt; # Include & lt; Algorithm & gt; Int main () {std :: string s = "I am a string"; Std :: Change (s.begin (), s.end (), '', ','); Std :: Court & lt; & Lt; S; }  

Output: I, am, a, string


Comments