title: Difference between pointer to pointer and pointer to array?
body: <p>Given that the name of an array is actually a pointer to the first element of an array, the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      int a[3] = {0, 1, 2};
      int *p;
  
      p = a;
  
      printf("%d\n", p[1]);
  
      return 0;
  }
  </code></pre>
  
  <p>prints <code>1</code>, as expected.</p>
  
  <p>Now, given that I can create a pointer that points to a pointer, I wrote the following:</p>
  
  <pre><code>#include &lt;stdio.h&gt;                                                              
  
  int main(void)                                                                  
  {                                                                               
          int *p0;                                                                
          int **p1;                                                               
          int (*p2)[3];                                                           
          int a[3] = {0, 1, 2};                                                   
  
          p0 = a;                                                                 
          p1 = &amp;a;                                                                
          p2 = &amp;a;                                                                
  
          printf("p0[1] = %d\n(*p1)[1] = %d\n(*p2)[1] = %d\n",                    
                          p0[1], (*p1)[1], (*p2)[1]);                             
  
          return 0;                                                               
  }
  </code></pre>
  
  <p>I expected it to compile and print</p>
  
  <pre><code>p0[1] = 1
  (*p1)[1] = 1
  (*p2)[1] = 1
  </code></pre>
  
  <p>But instead, it goes wrong at compile time, saying:</p>
  
  <pre><code>test.c: In function ‘main’:
  test.c:11:5: warning: assignment from incompatible pointer type [enabled by default]
  </code></pre>
  
  <p>Why is that assignment wrong? If <code>p1</code> is a pointer to a pointer to an <code>int</code> and <code>a</code> is a pointer to an <code>int</code> (because it's the name of an array of <code>int</code>s), why can't I assign <code>&amp;a</code> to <code>p1</code>?</p>