Question: // Problem 3: reverseOneString (15 points) // Reverse the string s by using pointer. // Use pointer p and 'temp' char to swap 1st char

// Problem 3: reverseOneString (15 points) // Reverse the string s by using pointer. // Use pointer p and 'temp' char to swap 1st char with last, then 2nd char with (last-1) and so on.. // Finally return pointer p which points to start of the reversed string. // You may declare and use more pointers if needed. // Hint: You might want to check if your logic works with even as well as odd length string. // You can write test code to print out the reversed string to check if your function works. (Don't include it in final submission) char* reverseOneString(char s[STRING_LENGTH]) { char temp; // not necessary to use this variable char *p = &s[0]; // pointer to start of string // enter code here

return p; }

// Problem 4: reverseStrings (5 points) // Reverse all the strings in 'strings[][]' // For each string in 'strings', use the reverseOneString() to reverse it. // You may declare and use more pointers if needed. void reverseStrings(char strings[NUM_STRINGS][STRING_LENGTH]) { char *ptr = &strings[0][0]; // enter code here

}

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!