title: Why can't I use this code to overwrite a string?
body: <p><b>Code</b>:</p>
  
  <pre><code>#include "stdio.h"
  #include "string.h"
  
  int main()
  {
    char *p = "abc";
    printf("p is %s \n", p);
    return 0;
  }
  </code></pre>
  
  <p><b>Output</b>:</p>
  
  <pre>p is abc</pre>
  
  <hr>
  
  <p><b>Code</b>:</p>
  
  <pre><code>#include "stdio.h"
  #include "string.h"
  
  int main()
  {
    char *p = "abc";
    strcpy(p, "def");
    printf("p is %s \n",p);
    return 0;
  }
  </code></pre>
  
  <p><b>Output</b>:</p>
  
  <pre>Segmentation fault (core dumped)</pre>
  
  <p>Could someone explain why this happens?</p>