title: Why the location pointed by a pointer to const is assignable by other variable?
body: <p>I have written this piece of code </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main() {
       int b = 15;
       const int *foo = &amp;b;
       //b = 20;
       *foo = 20;
       printf("%d", *foo);
       return 0;
  }
  </code></pre>
  
  <p>This means that the location that <code>foo</code> is pointing to cannot change. That means <code>b</code> cannot change . But when I uncomment the line <code>b = 20</code>. It doesn't show any error and I get the output <code>20</code> . While in this piece of code I get this error </p>
  
  <pre><code>main.c: In function 'main':
  main.c:15:10: error: assignment of read-only location '*foo'
        *foo = 20;
  </code></pre>
  
  <p>If <code>*foo</code> that is <code>b</code> is read only location, why can I change its value <code>b = 20</code>?</p>