Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "genlib.h"
- #include "simpio.h"
- #include <iostream>
- string CensorString(string input, string toRemove)
- {
- int toRemoveLength = toRemove.length();
- int beginning = input.find(toRemove);
- while (beginning !=string::npos){
- input.erase(beginning, toRemoveLength);
- beginning = input.find(toRemove);
- }
- return input;
- }
- int main()
- {
- cout << "Enter string to look in: ";
- string input;
- cin >> input;
- cout << "Enter string to remove: ";
- string toRemove;
- cin >> toRemove;
- string result = CensorString(input,toRemove);
- cout << result;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement