While compiling this below given code, I got the error: lvalue required as left operand of assignment for both the statements str+i = str+((len-1)-i);
and str+((len-1)-i) = temp;
.
Why?
char* str_reverse(char *str, int len)
{
char *temp;
int i, mid;
if(len%2 == 0)
{
mid = len/2 - 1;
}
else
{
mid = (len-1)/2;
}
for(i=0;i<mid;i++)
{
temp = str+i;
str+i = str+((len-1)-i);
str+((len-1)-i) = temp;
}
return str;
}