title: 'strncpy' vs. 'sprintf'
body: <p>I can see many <code>sprintf</code>'s used in my applications for copying a string.</p>
  
  <p>I have a character array:</p>
  
  <pre><code>char myarray[10];
  const char *str = "mystring";
  </code></pre>
  
  <p>Now if I want want to copy the string <code>str</code> into <code>myarray</code>, is is better to use:</p>
  
  <pre><code>sprintf(myarray, "%s", str);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>strncpy(myarray, str, 8);
  </code></pre>
  
  <p>?</p>