size_t strlcpy(char *s1,
               const char *s2,
               size_t n);

strlcpy copies up to n−1 characters from the string pointed to by s2 into the array pointed to by s1 and always terminates the result with a null character. The behavior of strlcpy is undefined if copying takes place between objects that overlap.

strlcpy returns the number of characters it tried to copy, which is the length of the string s2 or n, whichever is smaller.


strlcpy is commonly found in OpenBSD libraries and contrasts with strncpy in that the resulting string is always terminated with a null character.