Answers for "how to replace letter presents in the string in c++"

C++
6

c++ replace character in string

#include <algorithm>
#include <string>

void some_func() {
  std::string s = "example string";
  std::replace( s.begin(), s.end(), 'x', 'y'); // replace all 'x' to 'y'
}
Posted by: Guest on December-09-2020
0

how to replace part of string with new string c++

//String Replacement
#include <string>

int main(){
  //String before replacement
  string str = "We want to replace all of you";
  //use this inbuilt function
  str.replace(19,10,"me");
    
  cout<<str;
   
  return 0;
}
Posted by: Guest on October-08-2021

Code answers related to "how to replace letter presents in the string in c++"

Browse Popular Code Answers by Language