Confusion about zero-terminating character
<p>I've always had a question about null-terminated strings in C++/C. For example, if you have a character array like so:</p>

<pre><code>char a[10];
</code></pre>

<p>And then you wanted to read in characters like so:</p>

<pre><code>for(int i = 0; i &lt; 10; i++)
{
  cin &gt;&gt; a[i]; 
}
</code></pre>

<p>And lets in input the following word: questioner </p>

<p>as the input.</p>

<p>Now my question is what happens to the '\0'? If I were to reverse the string, and make it print out </p>

<pre><code>renoitseuq
</code></pre>

<p>Where does the null-terminating character go? I thought that good programming practice was to always leave one extra character for the zero-terminating character. But in this example, everything was printed correctly, so why care about the null-terminating character? Just curious. Thanks for your thoughts!</p>
