title: In C, are arrays pointers or used as pointers?
body: <p>My understanding was that arrays were simply constant pointers to a sequence of values, and when you declared an array in C, you were declaring a pointer and allocating space for the sequence it points to.</p>
  
  <p>But this confuses me: the following code:</p>
  
  <pre><code>char y[20];
  char *z = y;
  
  printf("y size is %lu\n", sizeof(y));
  printf("y is %p\n", y);
  printf("z size is %lu\n", sizeof(z));
  printf("z is %p\n", z);
  </code></pre>
  
  <p>when compiled with Apple GCC gives the following result:</p>
  
  <pre><code>y size is 20
  y is 0x7fff5fbff930
  z size is 8
  z is 0x7fff5fbff930
  </code></pre>
  
  <p>(my machine is 64 bit, pointers are 8 bytes long). </p>
  
  <p>If 'y' is a constant pointer, why does it have a size of 20, like the sequence of values it points to? Is the variable name 'y' replaced by a memory address during compilation time whenever it is appropiate? Are arrays, then, some sort of syntactic sugar in C that is just translated to pointer stuff when compiled?</p>