I am writing a code to reverse a string in place:
void ReverseInPlace(char * x)
{
char * end = x;
int i;
i = 0;
char temp;
while(*end)
{
++end;//point tol end
++i;//count the lenght
}
--end;
printf("%s",end);
printf("%d",i);
while(i)
{
temp = *end;
printf("%s","\n");
printf("%c",temp);
end--;
x++;
i--;
}
printf("%s","\n");//blank line
printf("%s","\n");//blank line
printf("%s","-----");//blank line
printf("%s",x);//print original
}
Here are my confusions:
Even though I am able to print the characters in reverse, I want to reverse the string without using an array
I get error when I try to do the following:
*x = temp;