.\"macro stdmacro .\" .\" Copyright (c) 2021 Ken McDonell. .\" .\" This program is free software; you can redistribute it and/or modify it .\" under the terms of the GNU General Public License as published by the .\" Free Software Foundation; either version 2 of the License, or (at your .\" option) any later version. .\" .\" This program is distributed in the hope that it will be useful, but .\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY .\" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License .\" for more details. .\" .\" .TH PMSTRNCPY 3 "PCP" "Performance Co-Pilot" .SH NAME \f3pmstrncpy\f1 \- safe string copy .SH "C SYNOPSIS" .ft 3 #include .sp int pmstrncpy(char *\fIdest\fP, size_t \fIdestlen\fP, char *\fIsrc\fP); .sp cc ... \-lpcp .ft 1 .SH DESCRIPTION .B pmstrncpy is safe string copying routine with semantics similar to .BR strncpy (3). .PP The main differences are that .I src must be null-byte terminated, .I destlen is the length of the destination buffer (\c .IR dest ) not the length of the source string (\c .IR src ), and .B pmstrncpy ensures that .I dest is null-byte terminated, even when \fIstrlen\fP(\fIsrc\fP) is larger than .IR destlen . .PP On success, .B pmstrncpy returns 0, else -1 indicates that .I src is too big and the result been truncated to ensure .I dest has no been overrun. .SH SEE ALSO .BR pmstrncat (3) and .BR strncpy (3).