ioctl_tty.2: Update DTR example
[man-pages.git] / man3 / stpcpy.3
blob199a7d87d88ceb30422f32cbe3eab0492ef99494
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  2021-03-22 "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 *restrict " dest ", const char *restrict " src );
33 .fi
34 .PP
35 .RS -4
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .RE
39 .PP
40 .BR stpcpy ():
41 .nf
42     Since glibc 2.10:
43         _POSIX_C_SOURCE >= 200809L
44     Before glibc 2.10:
45         _GNU_SOURCE
46 .fi
47 .SH DESCRIPTION
48 The
49 .BR stpcpy ()
50 function copies the string pointed to by
51 .I src
52 (including the terminating null byte (\(aq\e0\(aq)) to the array pointed to by
53 .IR dest .
54 The strings may not overlap, and the destination string
55 .I dest
56 must be large enough to receive the copy.
57 .SH RETURN VALUE
58 .BR stpcpy ()
59 returns a pointer to the
60 .B end
61 of the string
62 .I dest
63 (that is, the address of the terminating null byte)
64 rather than the beginning.
65 .SH ATTRIBUTES
66 For an explanation of the terms used in this section, see
67 .BR attributes (7).
68 .ad l
69 .nh
70 .TS
71 allbox;
72 lbx lb lb
73 l l l.
74 Interface       Attribute       Value
76 .BR stpcpy ()
77 T}      Thread safety   MT-Safe
78 .TE
79 .hy
80 .ad
81 .sp 1
82 .SH CONFORMING TO
83 This function was added to POSIX.1-2008.
84 Before that, it was not part of
85 the C or POSIX.1 standards, nor customary on UNIX systems.
86 It first appeared at least as early as 1986,
87 in the Lattice C AmigaDOS compiler,
88 then in the GNU fileutils and GNU textutils in 1989,
89 and in the GNU C library by 1992.
90 It is also present on the BSDs.
91 .SH BUGS
92 This function may overrun the buffer
93 .IR dest .
94 .SH EXAMPLES
95 For example, this program uses
96 .BR stpcpy ()
97 to concatenate
98 .B foo
99 and
100 .B bar
101 to produce
102 .BR foobar ,
103 which it then prints.
106 #define _GNU_SOURCE
107 #include <string.h>
108 #include <stdio.h>
111 main(void)
113     char buffer[20];
114     char *to = buffer;
116     to = stpcpy(to, "foo");
117     to = stpcpy(to, "bar");
118     printf("%s\en", buffer);
121 .SH SEE ALSO
122 .BR bcopy (3),
123 .BR memccpy (3),
124 .BR memcpy (3),
125 .BR memmove (3),
126 .BR stpncpy (3),
127 .BR strcpy (3),
128 .BR string (3),
129 .BR wcpcpy (3)