Description
The strncpy() function copies up to n characters, including the terminating null character, from the string pointed to by s2 into the buffer pointed to by s1.
Once strncpy() has copied n characters to s1, it does not append a terminating null character.The function strncpy() does not allocate any storage. The caller must insure that the buffer pointed to by s1 is long enough to hold the characters copied to it.
Syntax
char *strncpy(char *s1, const char *s2, size_t n)
Parameters
- s1
Points to a destination buffer.
- s2
Points to the source string to be copied into s1.
- n
Is the maximum number of characters to copy from s2 to s1.
Return Values
The strncpy() function returns the value of s1.