1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
denis-greek [22]
3 years ago
15

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;
Computers and Technology
1 answer:
Paraphin [41]3 years ago
4 0

Answer:

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.
You might be interested in
Hidden costs of computers into our schools
Gala2k [10]

Answer:

There are certainly many hidden costs, and you need to find them out. I am listing some. The GPU can cost a lot if you are using them for complex computing like in the case of Bitcoin. You need to pay heavy electricity bills as well. And if you want to install the webserver then as well, you need to keep your computer open all the time, and pay a good sum as an electricity bill. Many more hidden costs can be found. And one out of above is used in Schools, the webserver. Some more hidden costs can be Network cost, as the school is big, and you need to connect all through LAN, and at times we also need WAN set up. And these are another hidden cost. Various education licenses come for free, and smart classes cost as well. The video conferencing, VOIP, etc costs as well. Smart classes training by various computer training institute for teachers like one from adhesive.

Explanation:

Please check the answer section.

6 0
4 years ago
Double bar graphs compare multiple what
GalinKa [24]
You would multiply by 2
7 0
3 years ago
Name the two types of control systems.<br> PLEASE HELP THIS WAS DUE HOURS AGOOOO
vodomira [7]

Answer:

Open loop control systems.

Closed loop control systems.

Explanation:

5 0
4 years ago
Read 2 more answers
Which AWS service is a managed service that makes it easy to set up, operate, and scale a relational database in the cloud?​
vaieri [72.5K]

Answer:

I use Google cloud free tier for my Minecraft server

4 0
4 years ago
How to change the indent of the list item "regular" on slide 2 to .5 inches in powerpoint?
galina1969 [7]
<span>You can change the identation of text in Powerpoint by right clicking on the list item and selecting, "Format Text". On the paragraph tab, you can adjust the indentation before text as given in inches.</span>
4 0
3 years ago
Other questions:
  • You use worksheets to perform calculations. How do you perform these calculations?
    15·2 answers
  • Another html/css assignment, drop css code below, thank you
    15·1 answer
  • Uses of computer in daily life
    9·2 answers
  • Ideally an entity identifier is composed of _____ attribute(s).
    11·1 answer
  • Which cell formatting is most likely to use $?
    5·1 answer
  • A firm can survive and succeed in the long run if it successfully develops strategies to confront the _______________ that shape
    9·1 answer
  • Which do switches create?<br> Networks<br> Wireless access points<br> Routes<br> Collision domains
    13·1 answer
  • A mysql prompt has been opened for you. Using the college database, complete the following tasks (use either a single-line or a
    7·1 answer
  • How do I create a simple percentage function to gather a score for a quiz in PHP?
    14·1 answer
  • I will give brainliest to the best answer. what is a good screen recorder
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!