I am brand new to C. I am trying to make sure I understand dynamic memory allocation so I was coming up with examples on my own. When I stumbled on this I was not sure why this crashes. That is, I don't see what we have violated. Maybe one of the advanced C programmers here can explain to me. Can we not manipulate a string after we point it somewhere? Thanks in advance.
int main(){
char *name = (char*)malloc(sizeof(char)*10);
name = "Hello";
name[0] = 'X'; //<------ bad idea?
puts(name);
free(name);
char aname[sizeof(char)*10] = "Hello";
aname[0] = 'X';
puts(aname);
return 0;
}