Write change: Given two strings, change copies lines from the standard input to the standard output replacing all occurrences of the first string by the second. change is invoked by the command
change from toand prints the lines in the standard input changing all occurrences of the string from to the string to. The strings from and to do not have to be the same length. For example, if the file foo contains
Now is the time for all good men to come the aid of their country.the command
change the first <fooprints
Now is first time for all good men to come first aid of firstir country.The to string is optional; if it is omitted, the effect is to delete occurrences of the from string. Thus, the command
change the <fooprints
Now_is__time for_all_good_men to_come__aid_of_ir_country.where underscores denote spaces. Note the two spaces between is and time in the first line and between come and aid in the last line.
You may assume that most lines are no longer than 120 characters, but your program must behave `reasonably' with longer lines. Also, make sure your program does something reasonable with the `boundary' cases, e.g., a null from string (change "") or empty input. Briefly explain how you deal with these cases in your readme file.
An executable version of Dave Hanson's solution is available in /u/cs217/1/change. His implementation takes 29 lines and uses six different routines from the Standard C library.
/u/cs217/bin/submit 1 readme makefile change.cYou may use other computing facilities to develop your program, but the submitted version must compile with lcc and execute correctly on Arizona.
Due: submitted by 11:59pm, Mon. 2/8/1999.