Question: array c++ int replaceAll( string array1[ ], int n, char letterToReplace, char letterToFill ); This function should replace every occurrence of the letterToReplace value with
array c++
int replaceAll( string array1[ ], int n, char letterToReplace, char letterToFill ); This function should replace every occurrence of the letterToReplace value with the letterToFill value found in all the array elements of the passed array argument. Return the number of letters that were replaced or -1 if the array has no elements. For example, for the array people[ 5 ] shown above, replaceAll( people, 5, 'z', 'a' ) should return 0 and the array argument should be unchanged. However, replaceAll( people, -5, 'z', 'a' ) should return -1. And finally, for the array string data[ 4 ] = { "happy", "days", "are here", "again" }; replaceAll( data, 4, 'a', 'z' ) should return the value 5 and the array argument should be changed to: { "hzppy", "dzys", "zre here", "zgzin" };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
