Word replacement
The organization For Unoffensive Communication to Kids (F.U.C.K.) is a group of concerned parents that do not want their children to read foul language on the internet. They need some internet software that filters out all indecent words and replaces them with something more decent.
Make a program that finds all offensive words in a text and replaces them with more appropriate terms.
| indecent word | replacement |
| shit | bodily waste |
| fuck | sleep with |
| motherfucker | incestuous boy |
| asshole | lower body cavity |
| son of a bitch | orphan |
Hint:
Use the function strstr to search for a phrase in a text:
p = strstr(text, phrase);
This function returns a pointer to the first occurrence of phrase in text. If the phrase is not found then strstr returns the NULL pointer.
Example of how to use strstr:
char * text = "I love you";
char * phrase = "love"; char * p;
p = strstr(text, phrase);
if (p != 0) cout << p - text;
This will make p point to the word "love" in text. The output will be 2.