Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

replace_text, char * output_phrase, int max_length); It is assumed that input_ph

ID: 3658901 • Letter: R

Question

replace_text, char * output_phrase, int max_length); It is assumed that input_phrase is a char array of size MAX_SIZE, where you should define a constant named MAX_SIZE and assign the value 80 for this problem. This should hold one line from the input, and may contain a newline character at the end. The input parameters match_text and replace_text point to the strings referred to in the description which are entered on the command line. The input parameter max_length is the assumed maximum length of input_phrase, match_text, or replace_text. If replacement of text causes the maximum line length to be violated your function should truncate the output line so that the output array is no longer than max_length. Remember you may not use any code libraries other than that specified above, in particular you may NOT use the string. h library. Remember to use top down design - it may make sense to create your own utility functions, e.g. a function that returns the length of a string. It is recommended you test different componnents of your design separately. For example, it may make sense initially to "stub" out the function replace_chars () with a "do nothing" function first, so you can focus initially on getting the aspects of the program that do not involve text replacement to work. After this is working, you could then focus on getting the replace_chars () function to work correctly. Your output should match the examples below exactly. User input is shown in bold. For this problem, you need to use test 6. sh, which works exactly the same way as test 6. sh, but is tailored for this particular program. Note that running test. sh for test cases 2 and 3 will put a copy of inputHW6.txt into the directory from which you run test 6. sh, overwriting any existing version of inputHW6.txt. Also note that although a test case 5 is shown, one is not available through the test utility. It is shown to indicate to you that the usage message should reflect the name of the program, and should NOT simply say. /replace. Your code will fail test case number 4 unless your executable is also named . /replace. In this problem, you are asked to write a simple utility program for the replacement of text strings in a file. The program name should exectuable should be named replace. The program has three possible modes: replace match_texrt replace_text in_file out_file The replace program should replace match_text with replace_text in every line of the file in_file and write the result in a file named out_file. Each line in the file in_file is assumed to be terminated by a newline character " ". Within each line, each occurence of the character string match_text should be replaced by the character string replacej_text. If occurences of the text in match_text overlap, then only the first occurence of match_text is replaced with replacej_text. For example, if match_text is "xox" and replacej_text is "y", then if an input line is "xoxox xox", the output line is "yox y", even though there are three occurences of "xox" in the input line. The string match_text must be non-null, but replacej_text can be null, in which case every occurence of match_text should be removed. The replacement is done within each line only, and any occurence of match_text across line boundaries should be ignored. replace match_texrt replace_text in_file This is exactly as the previous mode, but the output is written to the standard output instead being written to a file, replace match_text replace_text This is exactly as in the previous mode, but the input is read from the standard input instead from a file. Note some of the examples use the UNIX pipe operator "|" on the command line to feed the output of one instance of your program to the input of another instance of your program. Also, if two consecutive quotes (single or double) are given on the command line, this can be used to denote a null string. When you are reading from the standard input (keyboard), you can type "control-D" (hold down the control and D keys simultaneously) in order to send the EOF (end of file) indication. The examples below refer to a file "inputHW6.txt" which is located in the . /public/test Files subdirectory. There should be a line of output following each line of input - i.e. dont wait until you reach EOF before you start the output of characters, instead output one line after each line is

Explanation / Answer

Are these 2 questions......?? and you said you would post the example...pls do it...