Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Replace 1 With 2 - A function to replace all occurrences of one character in an array with two characters, as long as the array
ReplaceWith A function to replace all occurrences of one character in an
array with two characters, as long as the array is large enough
to hold the additional characters. If the array cannot hold the
additional characters, the function should leave the array
unchanged. The function should return true if it changed the
values in the array and false if it did not.
ReplaceWith takes five arguments: a singlesubscripted array
of characters, the size of the array, a character to find, and
two characters to replace the found character with.
Consider the character array
char "graf fase";
pictured below:
The function call ReplaceWith; should
return true, and after the function call the array should hold
the values shown below:
Note: If the character array in the example above was of size
instead of the function call ReplaceWithx
; would return false and leave the array
unchanged since the array is not big enough to hold the
cstring "graph phase"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started