STRNCPY - copy characters from string.

(ANSI Standard)

Usage:

#include <string.h>
ptr = strncpy( s1, s2, N );

Where:

char *s1;
points to an area of memory that is to receive the copied characters. This must be able to hold at least N characters.
const char *s2;
points to the string from which characters will be copied.
size_t N;
gives the number of characters to copy.
char *ptr;
points to the copied string (i.e. "s1").

Description:

"strncpy" copies at most N characters from the string "s2" into the area of memory pointed to by "s1". If it encounters a '\0' before it has copied N characters, it pads "s1" to N characters by adding '\0' characters. If "s2" is more than N-1 characters long, the first N characters will be copied and the string "s1" will NOT receive the usual terminating '\0'.

See Also:

expl c lib strcpy

expl c lib memcpy

Copyright © 1996, Thinkage Ltd.