title: STL basic_string length with null characters
body: <p>Why is it that you can insert a '\0' char in a std::basic_string and the .length() method is unaffected but if you call <code>char_traits&lt;char&gt;::length(str.c_str())</code> you get the length of the string up until the first '\0' character?</p>
  
  <p>e.g.</p>
  
  <pre><code>string str("abcdefgh");
  cout &lt;&lt; str.length(); // 8
  str[4] = '\0';
  cout &lt;&lt; str.length(); // 8
  cout &lt;&lt; char_traits&lt;char&gt;::length(str.c_str()); // 4
  </code></pre>