title: How Are C Arrays Represented In Memory?
body: <p>I believe I understand how normal variables and pointers are represented in memory if you are using C. </p>
  
  <p>For example, it's easy to understand that a pointer Ptr will have an address, and its value will be a different address, which is the space in memory it's pointing to. The following code:</p>
  
  <pre><code>int main(){
      int x = 10;
      int *Ptr;
      Ptr = &amp;x;
  return 0;
  }
  </code></pre>
  
  <p>Would have the following representation in memory:</p>
  
  <pre><code>+---------------------+-------------+---------+
  | Variable Name       | Address     | Value   | 
  +---------------------+-------------+---------+
  | x                   | 3342        | 10      |
  +---------------------+-------------+---------+
  | Ptr                 | 5466        | 3342    |
  +---------------------+-------------+---------+
  </code></pre>
  
  <p>However I find it difficult to understand how arrays are represented in memory. For example the code:</p>
  
  <pre><code>int main(){
      int x[5];
          x[0]=12;
          x[1]=13;
          x[2]=14;
  
      printf("%p\n",(void*)x);
      printf("%p\n",(void*)&amp;x);
  
  return 0;
  }
  </code></pre>
  
  <p>outputs the same address twice (for the sake of simplicity 10568). Meaning that x==&amp;x. Yet *x (or x[0] in array notation) is equal to 12, *(x+1) (or x[1] in array notation) is equal to 13 and so on. How can this be represented? One way could be this:</p>
  
  <pre><code>+---------------------+-------------+----------+----------------------+
  | Variable Name       | Address     | Value    | Value IF array       |
  +---------------------+-------------+----------+----------------------+
  | x                   | 10568       | 10568    | 12                   |
  +---------------------+-------------+----------+----------------------+
  |                     | 10572       |          | 13                   | 
  +---------------------+-------------+----------+----------------------+
  |                     | 10576       |          | 14                   | 
  +---------------------+-------------+----------+----------------------+
  |                     | 10580       |          | trash                | 
  +---------------------+-------------+----------+----------------------+
  |                     | 10584       |          | trash                | 
  +---------------------+-------------+----------+----------------------+
  </code></pre>
  
  <p>Is this close to what happens, or completely off?</p>