having trouble with reversing a string using recursion, i want my function to take 1 parameter which is a pointer to the string and reverse it recursively,if possible.
here is what i have now:
Code:
void rev(char *str){
char t;
char *s=str;//point to the first character
char *e=str+(strlen(str)-1);//point to the last character
if(s>e)
{
return;
}
rev(str++);/*<---here is my problem,now the last character will be the same one after the first call and i dont want that i want it to be the character before the last and so on,any ideas?*/
t=*s;
*s=*e;
*e=t;
}