title: C++ string input
body: <p>My book says that if I want to read a string with a maximum length of 40 characters, I have to declare a variable with a length of 41, but it doesn't say why.</p>
  
  <pre><code>char name[41];
  cin &gt;&gt; name;
  cout &lt;&lt; name &lt;&lt; endl;
  </code></pre>
  
  <p>I know this is a newbie question and indeed I'm a C++ newbie.</p>
  
  <p>I hope you can help me. Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thanks for the answers, I didn't expect so much great information in such short time.</p>
  
  <ol>
  <li><p>Who is in charge of inserting the NULL terminator at the end of the char array?</p></li>
  <li><p>What happens with the "\n" after I press Enter?</p></li>
  </ol>
  
  <p>Thanks again.</p>