]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stpncpy.3
signal.7: Note async-signal-safe functions added by POSIX.1-2008 TC1
[thirdparty/man-pages.git] / man3 / stpncpy.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
89e3ffe9 3.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
fea681da
MK
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
fe382ebf 8.\" %%%LICENSE_END
fea681da
MK
9.\"
10.\" References consulted:
11.\" GNU glibc-2 source code and manual
12.\"
13.\" Corrected, aeb, 990824
fe0fefbf 14.TH STPNCPY 3 2015-03-02 "GNU" "Linux Programmer's Manual"
fea681da
MK
15.SH NAME
16stpncpy \- copy a fixed-size string, returning a pointer to its end
17.SH SYNOPSIS
18.nf
fea681da
MK
19.B #include <string.h>
20.sp
21.BI "char *stpncpy(char *" dest ", const char *" src ", size_t " n );
22.fi
79247bb1
MK
23.sp
24.in -4n
25Feature Test Macro Requirements for glibc (see
26.BR feature_test_macros (7)):
27.in
28.sp
29.BR stpncpy ():
ea91c3fd
MK
30.PD 0
31.ad l
32.RS 4
33.TP 4
34Since glibc 2.10:
35_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
36.TP
79247bb1
MK
37Before glibc 2.10:
38_GNU_SOURCE
ea91c3fd
MK
39.RE
40.ad
41.PD
fea681da 42.SH DESCRIPTION
60a90ecd
MK
43The
44.BR stpncpy ()
e4a0d6cb
MK
45function copies at most
46.I n
47characters from the string
48pointed to by
49.IR src ,
50including the terminating null byte (\(aq\\0\(aq),
51to the array pointed to by
52.IR dest .
53Exactly
54.I n
55characters are written at
56.IR dest .
57If the length
58.I strlen(src)
59is smaller than
60.IR n ,
61the
62remaining characters in the array pointed to by
63.I dest
64are filled
71d9e7ae 65with null bytes (\(aq\\0\(aq),
e4a0d6cb
MK
66If the length
67.I strlen(src)
0d2eda1a 68is greater than or equal to
e4a0d6cb
MK
69.IR n ,
70the string pointed to by
71.I dest
72will
71d9e7ae 73not be null-terminated.
fea681da
MK
74.PP
75The strings may not overlap.
76.PP
e4a0d6cb
MK
77The programmer must ensure that there is room for at least
78.I n
79characters
80at
81.IR dest .
47297adb 82.SH RETURN VALUE
60a90ecd 83.BR stpncpy ()
aa198ef9 84returns a pointer to the terminating null byte
e4a0d6cb
MK
85in
86.IR dest ,
87or, if
88.I dest
89is not null-terminated,
716fe466 90.IR dest + n .
f27f40b7 91.SH ATTRIBUTES
ea1e1b75
PH
92For an explanation of the terms used in this section, see
93.BR attributes (7).
94.TS
95allbox;
96lb lb lb
97l l l.
98Interface Attribute Value
99T{
f27f40b7 100.BR stpncpy ()
ea1e1b75
PH
101T} Thread safety MT-Safe
102.TE
47297adb 103.SH CONFORMING TO
e3948c69
MK
104This function was added to POSIX.1-2008.
105Before that, it was a GNU extension.
e06ba91b 106It first appeared in version 1.07 of the GNU C library in 1993.
47297adb 107.SH SEE ALSO
1709027c 108.BR strncpy (3),
0a4f8b7b 109.BR wcpncpy (3)