title: When is null character being used and what does it do?
body: <p>The title almost says it all but:
  1. I am reading a tutorial about character sequences and encountered a section that I do not really understand. They initialize an array of characters with a null character at the end like so:</p>
  
  <pre><code>char myword[] = { 'H', 'e', 'l', 'l', 'o', '\0' };
  </code></pre>
  
  <p>However, they do not really explain anything further about the null character(I have also tried to use google but sadly I did not find the answer I want). The tutorial says </p>
  
  <blockquote>
    <p>"By convention, the end of strings represented in character sequences
    is signaled by a special character: the null character"</p>
  </blockquote>
  
  <p>which to me means "Most of the times but not every time, a null character is used."
  So my first question is - When is the null character being used and when do you know if you have to input it explicitly?</p>
  
  <p>2.. I have this code:</p>
  
  <pre><code>char foo[22] = { 'H', 'e', 'l', 'l', 'o' };
  cout &lt;&lt; foo &lt;&lt; endl;
  </code></pre>
  
  <p>Where the output is: Hello</p>
  
  <p>But this is without me adding the null character and in the tutorial, they initialize the the array with a null character at the end as I showed previously even though that the output of both examples is the exact same?? :/</p>
  
  <p>So my second question is - What is it actually that the null character do?</p>
  
  <p>Thanks, your time is much appreciated!</p>