char *str = "string" ;
char *end = str;
while(*(end+1) != '\0') {
end++;
}
while(str < end) {
char temp = *str;
*str = *end;
*end = temp;
str++;
end--;
}`
EDIT:
Are both these*str = *end
, *str++ = *end
invalid?
The above code gives error at that line.
Aren't str
and end
pointing to a read only part in memory whether it be post increment?