Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write in C Language Description Please finish the following function char *replace(charsource, char constpattern, char constreplacement) A sequence of calls to this function replace the

Write in C Language

Description

Please finish the following function

char *replace(charsource, char constpattern, char constreplacement)

A sequence of calls to this function replace the pattern with replacement.

On a first call, the function expects a C string as argument for source, and this function scan for source to find the first pattern appear in source than replace it with replacement.

In subsequent calls, the function expects a null pointer and uses the position right after the end of the last replacement as the new starting location for scanning.

This function return source.

Please see following example.

char source[100] = "1223456789", pattern[10] = "2", replacement[10] = "123";

printf("%s", replace(source, pattern, replacement)); //Here should print out 112323456789

printf("%s", replace(source, pattern, replacement)); //Here should print out 11123323456789

printf("%s", replace(NULL, pattern, replacement)); //Here should print out 1112331233456789

function

char *replace(char *source, char const *pattern, char const *replacement)

{

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

2. How were various roles filled?

Answered: 1 week ago

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago