strncpy.3 (769B)
1 .TH strncpy 3 2 .SH NAME 3 strncpy - copy a string with a length limit 4 .SH SYNOPSIS 5 #include <string.h> 6 7 char *strncpy(char *restrict s1, const char *restrict s2, size_t n) 8 .SH DESCRIPTION 9 The 10 .BR strncpy () 11 function copies at most 12 .I n 13 characters from the array at 14 .I s2 15 into the array at 16 .IR s1 . 17 Characters that follow a null byte in 18 .I s2 19 are not copied. 20 .PP 21 Overlapping source and destination regions produce undefined behavior. 22 .PP 23 When the string at 24 .I s2 25 is shorter than 26 .I n 27 characters, the remaining positions in 28 .I s1 29 are filled with null bytes until exactly 30 .I n 31 bytes have been written. 32 .PP 33 When 34 .I n 35 is zero, nothing is copied. 36 .SH RETURN VALUE 37 The 38 .BR strncpy () 39 function returns its first argument, 40 .IR s1 . 41 .SH STANDARDS 42 ISO/IEC 9899:1999 Section 7.21.2.4