Question: Write a C function int undo_runs (char 7ine) that accepts a C string which modifies the array 7 ine such that all runs of characters

 Write a C function int undo_runs (char 7ine) that accepts a

Write a C function int undo_runs (char 7ine) that accepts a C string which modifies the array 7 ine such that all runs of characters are removed, with the number of characters removed being returned by the function. For example: Here are some examples (although note that your solution must work also work for characters other than those shown in the examples): - undo_runs("aaaaabbb") modifies the contents of the array to "ab" and returns 6 - undo_runs ("abababab") does not modify the contents of the array and returns 0 - undo_runs ("aaabbbaaabbb") modifies the contents of the array to "abab" and returns 8 - undo_runs("aaaaababb") modifies the contents of the array to "abab" and returns 5 - undo_runs("teetota17er") modifies the contents of the array to "tetota7er" and returns 2 . - undo_runs("") does not modify the contents of the array and returns 0 - undo_runs(NULL) returns 0 Note that the array passed to the function must be modified in place. For example, given the following code: char s [20]; strncpy (s, "aaaaababb", 20); int resu7t = undo_runs(s); printf("\%d \%s ", resu7t, s); the output produced would be: 4abab Some marks will be given for the quality of your solution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!