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