You can't because you are trying to modify const data.
change it to:
char My_St[] = "abcdef";
Then you will be able to change it.
Think about what you were doing, you were declaring a pointer that pointed to "abcdef"
. It IS a pointer, not an array of chars. "abcdef"
lives in the farm, I mean, in the .text
area of your program and that is immutable.
When you do it the way I've shown, you are telling the compiler: i'm declaring this array, that will have as many chars as are needed to accommodate "abcdef"
and also, as you are there, copy "abcdef"
to it.