Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- char s[256],s1[25],s2[25];
- void find_replace()
- {
- char aux[256],*p;
- p=strstr(s,s1);
- while(p)
- {
- fill(aux,aux+256,0);
- strncpy(aux,s,p-s);
- strcat(aux,s2);
- p=p+strlen(s1);
- strcat(aux,p);
- strcpy(s,aux);
- p=strstr(s,s1);
- }
- }
- int main()
- {
- cin.get(s,256);
- cin.get();
- cin.get(s1,256);
- cin.get();
- cin.get(s2,256);
- find_replace();
- cout<<s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement