Classwork 14: String Introduction
Thursday, August 10, 2012[Previous Classwork] [Next Classwork]
Complete the following:
- Create the file cw14.c for a classwork assignment and start your file as normal.
- Start your assignment with the given example code
- Modify the program so that it will accept an input string and search character from the user
- An example of running this program:
linux3[26]% ./cw14 Input string to search: test_string Input character to find: r Found character at index: 7
- Get that version of the program working first
- Then modify the program further so that it will replace the found character with a new character specified by the user
- Make sure you handle the situation where the character to replace does not occur in the string at all
- This new verison of the program should print out the modified string at the end of the program
- An example of running this program:
linux3[27]% ./cw14 Input string to search: test_string Input character to find: r Input character to replace with: X Replaced string: test_stXing
- Get this version of the program working
- Lastly, modify the program so that it will replace all occurances of the specified character with the replacement character
- An example of running this program:
linux3[27]% ./cw14 Input string to search: test_string Input character to find: t Input character to replace with: X Replaced string: XesX_sXring
- Once you are sure the program is done and working well, start a script using script
- Once the script is running, show you running the program three, using different strings and replacement characters each time, once where the character to replace does not occur in the string at all.
- Exit from the script, which will save the log typescript
- Once you are done, use submit to submit two files, cw14.c and typescript
linux3[26]% submit cs104 cw14 cw14.c typescript
- After submitting your files, you can verify your files were submitted by using the submitls command
- MAKE SURE YOU LOGOUT AFTER SUBMITTING THE ASSIGNMENT AND BEFORE LEAVING CLASS!