Reverse a given String Using Recursion.

Code Snippets 4 U
#include < stdio.h > 
#include < stdlib.h > 
#include < string.h >

  void strReverse(char * , int);
int main() {
  char * str = "ii I am Good and Printing Not Duplicate";
  // for ASCII characters only
  strReverse(str, strlen(str));

  return 0;
}

void strReverse(char * str, int length) {
  if (length < 0) return;
  length--;
  printf("%c", *(str + length));
  strReverse(str, length);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

one + nine =