]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/stpcpy.3
capabilities.7: Add pivot_root(2) to CAP_SYS_ADMIN list
[thirdparty/man-pages.git] / man3 / stpcpy.3
1 .\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH STPCPY 3 2019-03-06 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 stpcpy \- copy a string returning a pointer to its end
28 .SH SYNOPSIS
29 .nf
30 .B #include <string.h>
31 .PP
32 .BI "char *stpcpy(char *" dest ", const char *" src );
33 .fi
34 .PP
35 .in -4n
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .in
39 .PP
40 .BR stpcpy ():
41 .PD 0
42 .ad l
43 .RS 4
44 .TP 4
45 Since glibc 2.10:
46 _POSIX_C_SOURCE\ >=\ 200809L
47 .TP
48 Before glibc 2.10:
49 _GNU_SOURCE
50 .RE
51 .ad
52 .PD
53 .SH DESCRIPTION
54 The
55 .BR stpcpy ()
56 function copies the string pointed to by
57 .I src
58 (including the terminating null byte (\(aq\e0\(aq)) to the array pointed to by
59 .IR dest .
60 The strings may not overlap, and the destination string
61 .I dest
62 must be large enough to receive the copy.
63 .SH RETURN VALUE
64 .BR stpcpy ()
65 returns a pointer to the
66 .B end
67 of the string
68 .I dest
69 (that is, the address of the terminating null byte)
70 rather than the beginning.
71 .SH ATTRIBUTES
72 For an explanation of the terms used in this section, see
73 .BR attributes (7).
74 .TS
75 allbox;
76 lb lb lb
77 l l l.
78 Interface Attribute Value
79 T{
80 .BR stpcpy ()
81 T} Thread safety MT-Safe
82 .TE
83 .SH CONFORMING TO
84 This function was added to POSIX.1-2008.
85 Before that, it was not part of
86 the C or POSIX.1 standards, nor customary on UNIX systems.
87 It first appeared at least as early as 1986,
88 in the Lattice C AmigaDOS compiler,
89 then in the GNU fileutils and GNU textutils in 1989,
90 and in the GNU C library by 1992.
91 It is also present on the BSDs.
92 .SH BUGS
93 This function may overrun the buffer
94 .IR dest .
95 .SH EXAMPLE
96 For example, this program uses
97 .BR stpcpy ()
98 to concatenate
99 .B foo
100 and
101 .B bar
102 to produce
103 .BR foobar ,
104 which it then prints.
105 .PP
106 .EX
107 #define _GNU_SOURCE
108 #include <string.h>
109 #include <stdio.h>
110
111 int
112 main(void)
113 {
114 char buffer[20];
115 char *to = buffer;
116
117 to = stpcpy(to, "foo");
118 to = stpcpy(to, "bar");
119 printf("%s\en", buffer);
120 }
121 .EE
122 .SH SEE ALSO
123 .BR bcopy (3),
124 .BR memccpy (3),
125 .BR memcpy (3),
126 .BR memmove (3),
127 .BR stpncpy (3),
128 .BR strcpy (3),
129 .BR string (3),
130 .BR wcpcpy (3)