Hi,Can somebody write a sample code to reverse a string using recursion.Basically a function which takes string as input parameter, reverses the string using recusrion and returns back the reversed string to calling function.I have written this code:#include void rev_str(char* s){if(*s != '')rev_str(s+1);printf("%c",*s);}int main(){rev_str("born2c0de");return 0;}Here i am able to reverse the string and print it out...but i want rev_str function to return the reversed string or ideally reverse the passed string itself.Can you help me out?
Questions by varun51
Showing Answers 1 - 1 of 1 Answers
Hi,Can somebody write a sample code to reverse a string using recursion.Basically a function which takes string as input parameter, reverses the string using recusrion and returns back the reversed string to calling function.I have written this code:#include void rev_str(char* s){if(*s != '')rev_str(s+1);printf("%c",*s);}int main(){rev_str("born2c0de");return 0;}Here i am able to reverse the string and print it out...but i want rev_str function to return the reversed string or ideally reverse the passed string itself.Can you help me out?
Profile Answers by varun51 Questions by varun51
Questions by varun51