I would like to write a function in C that truncates an input string to 32 chars, but the code below gives me a segmentation fault. Could anyone explain why it is so?
void foo (char *value){
if (strlen(value)>32) {
printf("%c\n", value[31]); // This works
value[31] = '\0'; // This seg faults
}
}