title: When I subtract memory addresses, why is the result smaller than I expected?
body: <p>I have the following program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct X
  {
      int a;
      float b;
  } x[10], *p1, *p2;
  
  int main(int argc, char *argv[])
  {
      p1 = &amp;x[1];
      p2 = &amp;x[5];
  
      int i = p2 - p1;
  
      std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I can visualize <code>X</code>'s layout in memory, 10 boxes containing an <code>int</code> and a <code>float</code>, <code>p1</code> will point at the beginning of the second box (<code>x[1]</code>) and <code>p2</code> pointing at the beginning of the 6th box (<code>x[5]</code>):</p>
  
  <pre><code>   X   0   1  2  3  4  5  6  7  8  9
         _______________________________
      b  |__|__|__|__|__|__|__|__|__|__|
      a  |__|__|__|__|__|__|__|__|__|__|
            |           |    
            |           | 
            p1          p2
  </code></pre>
  
  <p>Is my drawing correct ? If so why is the result of <code>i</code> 4 ?<br>
  Having some difficulties understanding subtraction of two addresses ?</p>