Is it possible to reverse a string in place without using strlen, using recursion and with this definition?
void reverse(char *s, int dim);
The only thing I could do was:
void reverse(char *s, int dim)
{
int a = dim;
int b = strlen(s) - 1 - dim;
if ((a - b) <= 0)
return;
swap(s[a], s[b]);
reverse(s, dim - 1);
}
But I would like to do that without using strlen and without defining a similar function. Is it possible?
strlen, but you'd only do a worse job of it thatstrlenwould.)