int pmstrncpy(char *dest, size_t destlen, char *src);
cc ... -lpcp
pmstrncpy is safe string copying routine with semantics similar to strncpy(3).
The main differences are that src must be null-byte terminated, destlen is the length of the destination buffer (dest) not the length of the source string (src), and pmstrncpy ensures that dest is null-byte terminated, even when strlen(src) is larger than destlen.
On success, pmstrncpy returns 0, else -1 indicates that src is too big and the result been truncated to ensure dest has no been overrun.
pmstrncat(3) and strncpy(3).