Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

f. Did they change their names? For what reasons?

Answered: 1 week ago