Homework 11: Strings Homework
Wednesday, April 18, 2012[Up] [Previous Homework] [Next Homework]
Complete the following:
- NOTE: You need to start indenting your programs properly. Points will be taken off for not indenting this homework appropriately
- Reminder to look at CMSC104 Indentation Standards
- Create a new h11.c file
- You are going to implement a program to censor bad words
- Or, more generally, you are going to implement a program to search for a string inside another string and replace it
- Your program should take two strings (give a maximum size of 50 characters) as input from the user
- Your program should then search the first string to see if the second string occurs in it
- For every instance of the second string found inside the first string, all the characters that matched the second string should be replaced with X'es
- Your program should then print out the censored first string
- Example run:
linux2[1]% ./hw11 Input string: hey_this_is_a_test Input string to censor: is Censored string: hey_thXX_XX_a_test linux2[1]% ./hw11 Input string: more_test_to_show_testing_my_code Input string to censor: test Censored string: more_XXXX_to_show_XXXXing_my_code linux2[1]% ./hw11 Input string: more_test_to_show_testing_my_code Input string to censor: blah Censored string: more_test_to_show_testing_my_code
- Create a script of you running your program three times.
- Once you are done, use submit to submit two files, hw11.c and typescript
linux3[1]% submit cs104_sheets hw11 hw11.c typescript