Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
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