fork(4) download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. int len;
  6. void recursively_reverse(char *str,int i)
  7. {
  8. char temp;
  9. if(i==len/2)return;
  10. temp=*(str+i);
  11. *(str+i)=*(str+len-1-i);
  12. *(str+len-1-i)=temp;
  13. recursively_reverse(str,++i);
  14. }
  15.  
  16. void main()
  17. {
  18.  
  19. int i=0;
  20. char str[256];
  21. printf("enter the string to be reversed\n");
  22. scanf("%s",str);
  23. len=strlen(str);
  24. recursively_reverse(str,i);
  25. printf("the string str after reversing is %s\n",str);
  26. }
  27.  
  28.  
Runtime error #stdin #stdout 0s 2252KB
stdin
abcde
stdout
enter the string to be reversed
the string str after reversing is edcba