Question: Write a function named replaceBlanks that accepts a pointer to a C-string (an array of characters with a NULL terminating character) and it
Write a function named "replaceBlanks" that accepts a pointer to a C-string (an array of characters with a NULL terminating character) and it will replace all blanks in that C-string array with question mark ('?'). It will return three values: - the number of blanks that it has replaced with '?' - the number of '?' that was already in the C-string - the boolean flag that is true if after replacement, the C-string is all '?' and false otherwise.
For example, here are examples of C-string and its expected return values "One Two Three" will become "One?Two?Three" and it will return 2 blanks, 0 question mark and false "? ? " will become "????" and it will return 2 blanks, 2 question marks and true " " will become "?" and it will return 1 blank, 0 question mark and true "?" will become "?" and it will return 0 blank, 1 question mark and true "1" will become "1" and it will return 0 blank, 0 question mark and false "" will become "" and it will return 0 blank, 0 question mark and false "1?" will become "1?" and it will return 0 blank, 1 question mark and false "1 " will become "1?" and it will return 1 blank, 0 question mark and false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
