Write a recursive version of the function reverse(s), which reverses the string s in place.

#include <string.h>

/*reverse: reverse string s in place    */
void reverse(char s[]){
     void reverse(char s[], int i, int len);
    
     reverse(s, 0, strlen(s));
}
/* reverse: reverse string s in place: recursive    */
void reverse(char s[], int i, int len){
    int c , j;

    j = len - (i + 1);
    if (i < j){
        c = s[i];
        s[i] = s[j];
        s[j] = c;
        reverse(s, ++i, len);
    }
}

Leave a comment