A string literal such as "hey"or "jey"is a constant that you cannot change.
Statements
p = "hey";
p = "jey";
make ppoints to the first element of the assigned string. Although the language allows this, you are losing pointer information received from new, and now you have a memory leak.
You have the same problem in the second example, but you get segfault when you try to change a string literal with
p[0] = 'j';
, "hey" 0x01, 0x02 0x03 p 0x01. p[0] = 'j', , 0x01, , segfault.