title: If strncat adding NUL may cause the array go out of bound
body: <p>I have some trouble with strncat().The book called Pointers On C says the function ,strncat(),always add a NUL in the end of the character string.To better understand it ,I do an experiment.</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  int main(void)
  {
      char a[14]=&quot;mynameiszhm&quot;;
      strncat(a,&quot;hello&quot;,3);
      printf(&quot;%s&quot;,a);
      return 0;
  }
  </code></pre>
  <p>The result is mynameiszhmhel
  In this case the array has 14 char memory.And there were originally 11 characters in the array except for NUL.Thus when I add three more characters,all 14 characters fill up the memory of array.So when the function want to add a NUL,the NUL takes up memory outside the array.This cause the array to go out of bounds but the program above can run without any warning.Why?Will this causes something unexpected?
  So when we use the strncat ,should we consider the NUL,in case causes the array go out of bound?
  And I also notice the function strncpy don't add NUL.Why this two string function do different things about the same thing?And why the designer of C do this design?</p>