title: 0x00 and char arrays
body: <p>Why do char arrays stop right before a 0x00 byte is detected and how can this problem be avoided (perhaps by using another datatype (which one and why) or a "trick" with char)?</p>
  
  <p>For example in the following code, the output is "a" only, the other bytes are not displayed:</p>
  
  <pre><code>unsigned char cbuffer[]={0x61,0x00,0x62,0x63,0x0};
  std::string sbuffer=reinterpret_cast&lt;const char*&gt;(cbuffer);
  
  cout &lt;&lt; sbuffer &lt;&lt; endl;
  </code></pre>
  
  <p>Similarly in the following code, the output is "ab":</p>
  
  <pre><code>unsigned char cbuffer[]={0x61,0x62,0x00,0x63,0x0};
  std::string sbuffer=reinterpret_cast&lt;const char*&gt;(cbuffer);
  </code></pre>
  
  <p>Straightforward and effective workarounds to the problem (where 0x00 is kept in the array as a normal byte) would be appreciated.</p>