title: Why can't I assign an array to pointer directly in C?
body: <p>I have the following program. However, I can't understand why I have to pass the address of the array. When they are both pointing to the same address. Which is the address of the first element of the array of int's.</p>
  
  <p>I get a warning when I try and do this "assignment from incompatible pointer type":</p>
  
  <pre><code>ptr = var;
  </code></pre>
  
  <p>Complete source code:</p>
  
  <pre><code>void print_values(int (*ptr)[5])
  {
      size_t i = 0;
      for(i = 0; i &lt; 5; i++) {
          printf("%d: [ %d ]\n", i, (*ptr)[i]);
      }
  }
  
  int main(void)
  {
      /* declare a pointer to an array integers */
      int (*ptr)[5] = NULL;
      /* array of integers */
      int var[] = {1, 2, 3, 4, 5};
      /* assign the address of where the array is pointing to (first element) */
      ptr = &amp;var;
      /* Both are pointing to the exact same address */
      printf("var  [ %p ]\n",(void*)var);
      printf("&amp;var [ %p ]\n", (void*)&amp;var);
  
      print_values(ptr);
      return 0;
  }
  </code></pre>
  
  <p>I compile the code with <code>gcc 4.4.4 c89 -Wall -Wextra -O0</code></p>