Sorry ...correction we have to bring temp2 to last char again...!!!! so char* temp, temp2; char* s="Nitin"; for(temp2=s;*temp2='\0';temp2++ );/*just to calculate the length of s*/ --temp2; *<===================* void strrev(char * s,char* temp2) { if (s==temp2 ||s>temp2) {return;} *temp = *s; *s=* temp2; *temp2=*temp; temp2++; s++; strrev(*s,*temp2)
} On Thu, Sep 23, 2010 at 1:15 PM, coolfrog$ <dixit.coolfrog.div...@gmail.com>wrote: > char* temp, temp2; > char* s="Nitin"; > for(temp2=s;*temp2='\0';temp2++ );/*just to calculate the length of s*/ > > void strrev(char * s,char* temp2) > { if (s==temp2 ||s>temp2) > {return;} > *temp = *s; > *s=* temp2; > *temp2=*temp; > temp2++; > s++; > strrev(*s,*temp2) > > } > > But it is using two extra char pointer... is that allowed.....?? > > > On Thu, Sep 23, 2010 at 12:59 PM, 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<algogeeks%2bunsubscr...@googlegroups.com> >> . >> 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 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.