mbprez6029
04.03.2020 •
Computers and Technology
Int replace_text (Document *doc, const char *target, const char *replacement) The function will replace the text target with the text replacement everywhere it appears in the docu- ment. You can assume the replacement will not generate a line that exceeds the maximum line length; also you can assume the target will not be the empty string The function will return FAILURE if doc, target or replacement are NULL; otherwise the function will return SUCCESS. #de fine DOCUMENT H #de fine MAX PARAGRAPH LINES 20 #de fine MAX PARAGRAPHS 15 #de fine MAX STR SIZE 80 #de fine HIGHLIGHT START STR "[" #define HIGHLIGHT END STR "ן" #de fine SUCCESS #de fine FAILURE - typedef struct { int number of 1ines: char lines[MAX PARAGRAPH LINES 1 [MAX STR SIZE + 11 \ Paragraph; typedef struct { char name [ MAX STR SIZE+ 11 int number of paragraphs; Paragraph paragraphs [MAX PARAGRAPHS]; } Document;
Solved
Show answers
More tips
- L Leisure and Entertainment Mysteries of the Name Vyacheslav Dobrynin...
- F Food and Cooking Why Chicken Liver Pops and How It Can Affect Your Health?...
- F Food and Cooking Effective Methods to Organize Videos in your iPad According to Content...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
Answers on questions: Computers and Technology
- M Mathematics On friday, a local hamburger shop sold a combined total of 387 hamburgers and cheeseburgers. the number of cheeseburgers sold was two times the number of hamburgers sold. how many...
- P Physics What is the total number of electrons transported from the positive electrode to the negative electrode from the time the battery is first used until it is essentially dead?...
- M Mathematics Polynomial division (-12m^2-49mn-44n^2)/(-3m-4n)...
- M Mathematics Two-dimensional objects are measured by the quantity called 1 volume 2 height 3 length 4 area...
- M Mathematics The scatter plot and a line of best fit show the relationship between the hours spent sleeping and the hours spent watching TV. Which statement describes the relationship between...
Ответ:
int replace(Document *doc, const char *target, const char *replacement){
int i, j, k;
int beginning;
char temp[MAX_STR_SIZE + 1] ;
char *beginning, *end, *occ, *line;
if(doc == NULL || target == NULL || replacement == NULL)
return FAILURE;
for(i = 0; i < doc->total_paragraphs; i++){
for(j = 0; j < doc->paragraphs[i]->total_lines; j++){
line = doc->paragraphs[i]->lines[j];
beginning = line;
end = beginning + strlen(line);
strcpy(temp, "");
while(beginning < end && (occ = strstr(beginning, target))!= NULL){
len = occ - beginning;
strncat(temp, beginning, len);
strcat(temp, replacement);
beginning = occ + strlen(target);
}
strcat(temp, beginning);
strcpy(doc->paragraphs[i]->lines[j], temp);
}
}
return SUCCESS;
}
Explanation:
Loop through total paragraphs and total lines.Store the beginning and ending of paragraph in specific variables.Copy the remainging chars .Finally return SUCCESS.Ответ:
If you are in no rush, I recommend reading this website to find more on the uniqueness of carbon-
https://www.infoplease.com/math-science/chemistry/the-chemistry-of-biology-organic-chemistry