7 * Copy src to dst, truncating or null-padding to always copy n-1 bytes.
11 Strncpy(char *const dst
, const char *const src
, const size_t n
)
14 register const char *s
;
21 /* If they specified a maximum of n characters, use n - 1 chars to
22 * hold the copy, and the last character in the array as a NUL.
23 * This is the difference between the regular strncpy routine.
24 * strncpy doesn't guarantee that your new string will have a
25 * NUL terminator, but this routine does.
28 if ((*d
++ = *s
++) == 0) {
29 #if (STRN_ZERO_PAD == 1)
33 #endif /* STRN_ZERO_PAD */
37 /* If we get here, then we have a full string, with n - 1 characters,
38 * so now we NUL terminate it and go home.