title: Char pointers and the printf function
body: <p>I was trying to learn pointers and I wrote the following code to print the value of the pointer:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
      int main(void) {
          char *p = "abc";
          printf("%c",*p);
          return 0;
      }
  </code></pre>
  
  <p>The output is:</p>
  
  <blockquote>
    <p>a</p>
  </blockquote>
  
  <p>however, if I change the above code to:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      char *p = "abc";
      printf(p);
      return 0;
  }
  </code></pre>
  
  <p>I get the output:</p>
  
  <blockquote>
    <p>abc</p>
  </blockquote>
  
  <p>I don't understand the following 2 things:</p>
  
  <ol>
  <li><p>why did printf not require a format specifier in the second case? Is <code>printf(pointer_name)</code> enough to print the value of the pointer?</p></li>
  <li><p>as per my understanding (which is very little), *p points to a contiguous block of memory that contains <code>abc</code>. I expected both outputs to be the same, i.e. </p></li>
  </ol>
  
  <blockquote>
    <p>abc</p>
  </blockquote>
  
  <p>are the different outputs because of the different ways of printing?</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Additionally, the following code produces a runtime error. Why so?</p>
  
  <pre><code> #include &lt;stdio.h&gt;
  
      int main(void) {
          char *p = "abc";
          printf(*p);
          return 0;
      }
  </code></pre>