Advertisement
catalyn

inlocuire s1,s siruri

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