DOKK / manpages / debian 12 / libpcp3-dev / pmstrncpy.3.en
PMSTRNCPY(3) Library Functions Manual PMSTRNCPY(3)

pmstrncpy - safe string copy

#include <pcp/pmapi.h>

int pmstrncpy(char *dest, size_t destlen, char *src);

cc ... -lpcp

pmstrncpy is safe string copying routine with semantics similar to strncpy(3).

The main differences are that src must be null-byte terminated, destlen is the length of the destination buffer (dest) not the length of the source string (src), and pmstrncpy ensures that dest is null-byte terminated, even when strlen(src) is larger than destlen.

On success, pmstrncpy returns 0, else -1 indicates that src is too big and the result been truncated to ensure dest has no been overrun.

pmstrncat(3) and strncpy(3).

PCP Performance Co-Pilot