title: C language: How exactly is the size of an array calculated in C
body: <p>Memory addresses specify how many bytes of data they point to in memory, so it seems that the size of any variable is determined by looking at the memory address and seeing how much the variable occupies in memory. So how is the size of an array determined??? - because an array is a pointer to only the first item in the array by default:</p>
  
  <pre><code>int main() {
      int a[] = {1,2,3,4,5};
      // both show same memory address
      printf("%p\n", a);
      printf("%p\n", &amp;a[0]);
      // somehow the entire size of a is calculated
      printf("%lu\n", sizeof(a)); // 20 (all elements)
      return 0;
  }
  </code></pre>