I have this in an exercise with pointers:
char *str = "Hello";
int count = 0;
int len = 5;
printf("%c\n", *(str + count));
printf("%c\n", *(str + len - count - 1));
*(str + count) = *(str + len - count - 1);
Both *(str + count)
and *(str + len - count - 1)
are valid values as the printf
s attest (I get H
and o
). So why do I get a bus error
when I run the above?