title: what is the difference Global constant variable vs local constant variable in C
body: <p>I want to know the difference between local and global constants because I tried these examples and there are different results </p>
  
  <p>in this example </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  const int  x = 5;
  
  int main()
  {
      int* ptr = &amp;x;
      *ptr= 10;
      printf("%d",*ptr);
  }
  </code></pre>
  
  <p>it returns segmentation fault</p>
  
  <p>but in this example x changes and i know this way </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
      const int  x = 5;
      int* ptr = &amp;x;
      *ptr= 10;
      printf("%d",*ptr);
  }
  </code></pre>