My exercise says I need to write a recursive function to reverse a given string, using this prototype:
void reverse(char s[]);
The only pre-written function I’m allowed to use is strlen() from string.h library.
I have no clue where to begin from.
Start by having your function call another function that performs the actual recursion:
This might be more familiar recursive signature:
Since you cannot use helper functions:
This is homework and it sounds like you do not just want the answer so ask yourself the following questions.
What is your base case?
We know that reversing a 2 length char array is trivial, but how do you reverse a 3 length char array?
What do a pass to my recusive calls of
reverse?