title: How are integers alloted memory in C++?
body: <pre><code>#include&lt;iostream&gt;
  using namespace std;    
  
  int main() {
      int buf[2];
      buf[0]=65,buf[1]=66;
      char *p=(char*)(&amp;buf[0]);
      for(int i=0;i&lt;8;i++)
          cout&lt;&lt;(int)*(p+i)&lt;&lt;&quot; &quot;;
      return 0;
  }
  </code></pre>
  <p>I was trying to understand the memory allocation using above code. The output of the above code is:</p>
  <pre><code>65 0 0 0 66 0 0 0
  </code></pre>
  <p>Why are all the values 0 except for 'p' and 'p+4', when 'p+1', 'p+2','p+3' represent the 1st integer block containing 65 and 'p+5', 'p+6','p+7' represent the 2nd integer block?</p>
  <p>Please correct me if I'm wrong.</p>