and yes, "s" will be stored in stack everytime you call the function,
so its a temp variable..

string reverse is a simple logic, just iterate i through 1 to n/2 and
swap the i to n-i

On Mon, Jun 27, 2011 at 10:06 PM, Vishal Thanki <[email protected]> wrote:
> this code will only print, it will not store the reverse string.
>
> On Mon, Jun 27, 2011 at 9:53 PM, Kamakshii Aggarwal
> <[email protected]> wrote:
>> #include <stdio.h>
>> #include <stdlib.h>
>> void revers(char *s)
>> {
>>      if(*s)
>>      {
>>                     revers(++s);
>>                     s--;
>>                     printf("%c ",*s);
>>      }
>>
>> }
>> int main(int argc, char *argv[])
>> {
>>     char arr[]="string";
>>     revers(arr);
>>
>>   system("PAUSE");
>>   return 0;
>> }
>> will s be counted as temporary variable in this?
>> On Mon, Jun 27, 2011 at 8:57 PM, rShetty <[email protected]> wrote:
>>>
>>> Reversing a String without using a temporary variable ?
>>>
>>>
>>> Rajeev N B
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Kamakshi
>> [email protected]
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>

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

Reply via email to