Why these two code snippets have different behaviors
char p[] = "hello";
p[0] = 'W'; //works fine
While this gives a segmentation fault
char *ptr = "hello";
ptr[0] = 'W'; // undefined behavior
What is the difference between both codes,why i am unable to modify the string using pointer?