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) { }
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
Solved in 3 steps with 1 images