src/lib/common/string.c
/// Safely copy all or part of a string
///
/// The strncpy() function copies the string pointed to by \a src (including
/// the terminating null character) to the array pointed to by \a dest, except
/// that no more than \a n bytes of \a src are copied. This, if there is no
/// null byte among the first \a n bytes of \a src, the result will not be
/// null-terminated. In the case where the length of \a src is less than \a n,
/// the remainder of \a dest will be padded with null bytes.  The strings may
/// not overlap.
///
/// The strncpy() function return a pointer to the destination string \a dest.
Safely copy all or part of a string
The strncpy() function copies the string pointed to by \a src (including
the terminating null character) to the array pointed to by \a dest, except
that no more than \a n bytes of \a src are copied. This, if there is no
null byte among the first \a n bytes of \a src, the result will not be
null-terminated. In the case where the length of \a src is less than \a n,
the remainder of \a dest will be padded with null bytes.  The strings may
not overlap.

The strncpy() function return a pointer to the destination string \a dest.
Safely copy all or part of a string The strncpy () function copies the string pointed to by \ a src ( including the terminating null character ) to the array pointed to by \ a dest except that no more than \ a n bytes of \ a src are copied . This if there is no null byte among the first \ a n bytes of \ a src the result will not be null - terminated . In the case where the length of \ a src is less than \ a n the remainder of \ a dest will be padded with null bytes . The strings may not overlap . The strncpy () function return a pointer to the destination string \ a dest .
char *
strncpy(char *dest, const char *src, size_t n)
{
    char *rv = dest;
    while (*src && n--) {
        *dest++ = *src++;
    }
    memset(dest, 0, n);
    return rv;
}
char * strncpy ( char * dest , const char * src , size_t n ) { char * rv = dest ; while ( * src && n -- ) { * dest ++ = * src ++ ; } memset ( dest , 0 , n ) ; return rv ; }
Safely copy all or part of a string
The strncpy() function copies the string pointed to by \a src (including
the terminating null character) to the array pointed to by \a dest, except
that no more than \a n bytes of \a src are copied.
Safely copy all or part of a string The strncpy () function copies the string pointed to by \ a src ( including the terminating null character ) to the array pointed to by \ a dest except that no more than \ a n bytes of \ a src are copied .