char * strRev(char* string)
{
     static int ptr;

     if(ptr == lengthOf(string)/2 || ptr == lengthOf(string/2)+1)
            {
               return string;
            }
   ptr++;
   strRev(swap(string, ptr-1, lengthOf(string)-ptr-2));

}
where swap returns a string with the chars at the two positions
swapped.

I haven't tried out the code, but something along those lines should
work. I've used a static var coz of the Qs strict method signature
requirement.

where swap is a function that swaps the two chars
On Sep 23, 10:59 am, Albert <alberttheb...@gmail.com> wrote:
> How to reverse a String using recursion in C without using any extra
> memory?
>
> the question seems to be simple.....
>
> char* strrev(char *)
> {
>     ...
>     ...
>     ...
>
> }
>
> Try to give all the answers for this prototype.....

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to