strncpy() — Copy String

Format

#include <string.h>

char *strncpy(char * __restrict__string1, 
const char * __restrict__string2, size_t count);

General Description

The strncpy() built-in function copies at most count characters of string2 to string1. If count is less than or equal to the length of string2, a NULL character (\0) is not appended to the copied string. If count is greater than the length of string2, the string1 result is padded with NULL characters (\0) up to length count.

If copying takes place between objects that overlap, the behavior is undefined.

Returned Value

The strncpy() function returns string1.

Related Information