title: Printing array element memory adresses C and C++, why different output?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5657123/how-to-simulate-printfs-p-format-when-using-stdcout">How to simulate printf&#39;s %p format when using std::cout?</a>  </p>
  </blockquote>
  
  
  
  <p>I try to print out the array element memory addresses in C and C++.</p>
  
  <p>In C:</p>
  
  <pre><code>char array[10];
  int i;
  for(i =0; i&lt;10;i++){
      printf(" %p \n", &amp;array[i]);
  }
  </code></pre>
  
  <p>I got the memory addresses: <code>0xbfbe3312</code>, <code>0xbfbe3313</code>, <code>0xbfbe3314</code>, <code>...</code>.</p>
  
  <p>But if I try to make the same in C++:</p>
  
  <pre><code>char array[10];
  for(int i =0; i&lt;10;i++){
      std::cout&lt;&lt;&amp;array[i]&lt;&lt;std::endl;
  }
  </code></pre>
  
  <p>I got this output:</p>
  
  <blockquote>
    <p>�  </p>
    
    <p>P��<br>
    ��<br>
    �  </p>
    
    <p>k�<br>
    �<br>
    <br />
    <br /></p>
  </blockquote>
  
  <p>Why is it different? Should I use the <code>cout</code> differently in C++ to print out the memory addresses? How should I print out the memory addresses?</p>