The following code results in a seg fault, when running in GDB it appears when the memory is changed to decrease the character by 32.
#include <stdio.h>
char *upper(char *);
int main(void) {
char *my_word = "hello";
printf("Upper: %s\n", upper(my_word));
return 0;
}
char *upper(char *string) {
while(*string != '\0') {
*string -= 32;
string++;
}
return string;
}