Synopsis
#include <string.h>
char *strncpy(char *s1, const char *s2, size_t n);
Description

strncpy copies not more than n characters from the array pointed to by s2 to the array pointed to by s1. Characters that follow a null character in s2 are not copied. The behaviour of strncpy is undefined if copying takes place between objects that overlap. If the array pointed to by s2 is a string that is shorter than n characters, null characters are appended to the copy in the array pointed to by s1, until n characters in all have been written.

strncpy returns the value of s1.

Portability

strncpy conforms to ISO/IEC 9899:1990 (C90) and ISO/IEC 9899:1999 (C99).