I'm learning C, and I encountered a problem when I tried to increment letters in a string. Consider the code below:
int main() {
char *s = "abcdefg";
increment(s);
printf("%s\n", s);
}
void increment(char *string) {
for (int i = 0; string[i] != 0; i++) {
(*(string + i))++;
}
}
Currently I'm using C99. After I tried executing this, it gives be Bus Error: 10. I don't know why this is the case. Thanks!