So I want to find a word "ha" from my string(str) and replace it with "wk" from another string(str2) like this:
#include <iostream> #include <conio.h> #include <string> using namespace std; int main () { string str; cin>>str; string str2("ha"); while (str.find(str2) != std::string::npos) { str.replace(str.find(str2),str2.length(),"wk"); cout << str << endl; } return 0; } But the problem is that i can't make it work when i start the var1 with another word like "lol haha". not working when not haha at first[1]
Thank You :)
using namespace std;: stackoverflow.com/questions/1452721