Reversive Recursive


SUBMITTED BY: Guest

DATE: April 18, 2013, 10:21 p.m.

FORMAT: C++

SIZE: 788 Bytes

HITS: 1116

  1. /*****************************************************
  2. * Created By: Outsider
  3. * Purpose: Just a simple recursive function that returns
  4. * the mirror of an input string.
  5. *****************************************************/
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. char* reversive_recursion(char *);
  10. int main(void){
  11. char myString[255] = "Yeah, whatever I'm a string...";
  12. printf("%s\n", reversive_recursion(myString));
  13. system("PAUSE");
  14. }
  15. char* reversive_recursion(char *myString){
  16. char *a = myString;
  17. if(*(myString+1) != '\0'){
  18. return strncat(reversive_recursion(++myString), a, 1 );
  19. }
  20. else
  21. return myString;
  22. }

comments powered by Disqus