I keep getting segfaults when trying to run the code below. It seems Runtime error due to the line the *end = *begin; . Why is that?


#include <stdio.h>
#include <string.h>

void my_strrev(char* begin)
{
char temp;
char* end;
end = begin + strlen(begin)-1;

while(end>begin){
temp = *end;
*end = *begin;
*begin = temp;
end--;
begin++;
}
}

main()
{
char *string = "school";
my_strrev(string);
printf("%s", string);
}