Given a string, reverse the string recursively calling the reverse function without swapping the characters of the string
#include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX 256 int i=0; //Global Variable to have a counter variable in static context void reverse(char **s) { /* Until the end of the string ('\0' , the null character) is reached */ if(**s=='\0') return; /* Increment the Address the pointer is pointing to */ *s=*s+1; /* Call recursively for the rest of the string */ reverse(s); i++; /* Print the characters in reverse */ printf("%c",*(*s-i)); } int main(void) { char *s; /* Dynamically allocate the memory for the input string */ s=(char*)malloc(sizeof(char)*MAX); /* Get the input string from the user */ scanf("%s",s); /* Call the recursive function to reverse the string */ reverse(&s); return 0; }