Käynnissä

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ää: write program simulates search replace operation text editor, write program simulates search replace, text string search, substring search, substring in c, substring c, string the, string search in c, search text string, search substring, search string in c, search string c, search c string, search character in string, programming text editor, programming editor, c substring, c string substring, c string search, c search string, continue line in c, program simulates search replace operation text editor, search replace program function calls main, write program simulates replace text, write program simulates search replace operation

Tietoa työnantajasta:
( 43 arvostelua ) san jose, United States

Projektin tunnus: #4295388

Myönnetty käyttäjälle:

omaralieissa

good luck for both of us

$2 USD / tunti
(3 arvostelua)
1.6