title: Pointers to constants in C
body: <p>I compiled the following code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      // your code goes here
  
      char *consta = "ABC";
  
      printf("Use of just const: %c\n", consta );
      printf("Use of const[1]: %c\n", consta[1]);
      printf("Use of whole string: %s", consta);
  
      return 0;
  }
  </code></pre>
  
  <p>However, the output that I get is: </p>
  
  <pre><code>Use of just const: P
  Use of const[1]: B
  Use of whole string: ABC
  </code></pre>
  
  <p>The second printf and the third printf function calls work as expected however, I was expecting 'A' to be printed instead of 'P' in the first call to printf. </p>