 <p>The extra "stuff" is there because you've passed the buffer size to <code>memcpy</code>. It's going to copy that many characters, even when the source is shorter.</p> <p>I'd do things a bit differently:</p> <pre><code>void copy_string(char *dest, char const *src, size_t n) { *dest = '\0'; strncat(dest, src, n); } </code></pre> <p>Unlike <code>strncpy</code>, <code>strncat</code> is defined to work how most people would reasonably expect.</p>