Advertisement
icatalin

find_replace c++ inlocuire in sir multipla

Jan 21st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. char s[256],s1[25],s2[25];
  7.  
  8. void find_replace()
  9. {
  10.     char aux[256],*p;
  11.     p=strstr(s,s1);
  12.     while(p)
  13.     {
  14.         fill(aux,aux+256,0);
  15.         strncpy(aux,s,p-s);
  16.         strcat(aux,s2);
  17.         p=p+strlen(s1);
  18.         strcat(aux,p);
  19.         strcpy(s,aux);
  20.         p=strstr(s,s1);
  21.     }
  22. }
  23.  
  24. int main()
  25. {
  26.     cin.get(s,256);
  27.     cin.get();
  28.     cin.get(s1,256);
  29.     cin.get();
  30.     cin.get(s2,256);
  31.     find_replace();
  32.     cout<<s;
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement