STRLCAT 3CW "24 January 2007" "mathcw-1.00"
Table of contents
strlcat - size-bounded character-string concatenation
cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]
#include <string.h> (on BSD Unix systems only)
#include <mathcw.h>
extern size_t strlcat (char *target, const char *source, size_t target_length);
strlcat
copies characters from
source
to the end of
target,
stopping just before the first NUL in
source,
or when the number of characters copied, plus the initial length of
target,
has reached
target_length - 1.
A string-terminating NUL is then written to
target
as long as
target_length
is larger than zero, and larger than the initial length of
target.
Both
source
and
target
must be NUL-terminated strings.
This function is safer and more convenient than the Standard C
strcat()
function, which lacks target overrun detection, and its companion,
strncat(),
whose length argument refers to the number of characters to be copied,
rather than the size of
target.
strlcat()
returns the number of characters in
source,
plus the initial number of characters in
target.
If this is larger than
target_length,
then
target
is not large enough to hold the concatenation of the two strings.
The
target
string is NUL-terminated provided it initially had at least one byte
free.
strlcpy(3CW).