title: C++ - char array and the null character
body: <p>I have two questions about char array.</p>
  
  <ol>
  <li><p>from the code bellow, since <code>arr</code> is <code>const</code>, why doesn't the compiler give me an error since I'm rewriting it?</p>
  
  <pre><code>char arr[5]; // arr is a const pointer to (*)[5] array
  cin&gt;&gt;arr; //   
  </code></pre></li>
  <li><p>when I initialized a char array like this:</p>
  
  <pre><code>char arr[5]={'h','i'};
  </code></pre>
  
  <p>if I did this:</p>
  
  <pre><code>cout &lt;&lt; arr &lt;&lt; "something here \n"; 
  </code></pre>
  
  <p>it will print <code>hisomething here</code>. I thought It should print out </p>
  
  <pre><code>hi   something here
  </code></pre>
  
  <p>with 3 witespaces.</p>
  
  <p>But if I did this:</p>
  
  <pre><code>for(int i = 0; i &lt; 5; i++){
    cout &lt;&lt; arr[i];
  }
  </code></pre>
  
  <p>it <em>will</em> printout the 3 whitespaces.</p></li>
  </ol>
  
  <p>The second case seems to prove that the compiler doesn't add any null characters. So how can the compiler ignore the 3 whitespaces?</p>