Write a program that simulates the search and replace operation in a text editor.

Write a program that simulates the search and replace operation in a text editor. The program is to have only three function calls in main. The first prompts the user to type a string of 80 characters, then prmpts the user to search a substring of 10 or fewer characters, finally it prompts the user to type the replace substring of 10 or fewer characters.

The second call is the search and replace function, which replaces all occurences of the search substring with the replace substring and creates a new string. If no occurrences are found it returns the original string. The new string culd be 800 characters long (80 identical characters replaced by 10 characters each). Your function must be able to handle overfow by using the realloc function to exten the new string when neccessary. Start with an output string of 80 characters then extend by 80 when necessary. the function returns the adress of the new string.

After the search and replace function returns, a print function prints the resulting string as a series of 80 character lines. It performs word wrap. That is a line can end only at a space. if there is no space in 80 characters then print 79 characters and a hyphen and continue on the next line.

rune the program at least three times:

a. first run it with no substitutions in the original input

b. second run it with two or more substitutions

c. finally run it with substitutions that cause the output to be at least three lines one of which requires a hyphen.

Taidot: C-ohjelmointi

Näytä lisää: text string search, substring search, substring c, string the, search text string, search substring, search character string, programming text editor, programming editor, c substring, string substring, search string, continue line, series programming, write a, line editor, string search, search editor, 800 lines, replace word text program, word replace, substring using, substring, search adress, search replace

About the Employer:
( 43 reviews ) san jose, United States

Projektin tunnus: #4295388

Myönnetty käyttäjälle:


good luck for both of us

$2 USD / tunti
(3 arvostelua)