Why does this program give segmentation fault
int main()
{
    char *ptr;
    ptr = (char *)malloc(15*sizeof(char));
    ptr = "string";
    strcpy(ptr,"NewString");
}
while this does not
int main()
{
    char *ptr;
    ptr = (char *)malloc(15*sizeof(char));
    strcpy(ptr,"String");
    ptr = "Newstring";
}
OR the similar program when one literal in the string is to be modified
int main()
{
    char *ptr;
    ptr = "string";
    ptr[1] = 's';
}
when this does not
int main()
{
    char *ptr;
    ptr = (char *)malloc(15*sizeof(char));
    strcpy(ptr,"String");
    ptr[1] = 's';
}
 
     
    