Advertisement
Guest User

Untitled

a guest
Mar 26th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include "genlib.h"
  2. #include "simpio.h"
  3. #include <iostream>
  4.  
  5. string CensorString(string input, string toRemove)
  6. {
  7.     int toRemoveLength = toRemove.length();
  8.     int beginning = input.find(toRemove);
  9.     while (beginning !=string::npos){
  10.         input.erase(beginning, toRemoveLength);
  11.         beginning = input.find(toRemove);
  12.     }
  13.  
  14.     return input;
  15. }
  16.  
  17. int main()
  18. {
  19.     cout << "Enter string to look in: ";
  20.     string input;
  21.     cin >> input;
  22.     cout << "Enter string to remove: ";
  23.     string toRemove;
  24.     cin >> toRemove;
  25.     string result = CensorString(input,toRemove);
  26.     cout << result;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement