strncpy [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
strncpy
Copies all or part of s2 into s1.
Syntax
#include <string.h>
char *strncpy(char *s1, const char *s2, size_t n);
Parameters
s1 A pointer to a destination.
s2 A pointer to a null-terminated source character string.
n The maximum number of characters to copy from s2 to s1.
Return Values
x The address of s1.
Description
In the strncpy function, s2 is a character pointer to the string to be
copied, and s1 is a character pointer to the beginning of the string into
which the contents of string s2 are copied. The strncpy function copies
up to n characters, or up to and including the first encountered null
character, whichever occurs first. If strncpy() encounters a null before
copying n characters, it pads the string s1 with nulls up to n
characters. String s2 does not have to be null-terminated when using
strncpy() if n is less than or equal to the length of s2. If there is no
null character in the first n characters of s2, the result is not
null-terminated. If the strings overlap, behavior is undefined.
See Also
memcpy(), memmove(), strcat(), strcpy(), strlen(), strncat(), ANSI C
4.11.2.4, POSIX.1 8.1
MPE/iX 5.0 Documentation