strncpy

Syntax

char* strncpy(char* dest, const char* src, int n)

Arguments

dest
The string to which the source string is to be copied.
src
The string which is to be copied to the destination string.
n
The maximum number of characters to copy.

Return

A pointer to the destination string, identical to dest.

Description

Copies the first n characters of string src to the string dest.
If n is less than or equal to the length of src, a null character
is not appended automatically to the copied string. If n is greater than
the length of src, the destination string is padded with null characters up to length n.
The string dest must be large enough to hold n characters, otherwise results are undefined.
The behavior of strncpy is undefined if the source and destination strings overlap.

Also see

strcpy