OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / 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  2014-05-10 "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 .sp
32 .BI "char *stpcpy(char *" dest ", const char *" src );
33 .fi
34 .sp
35 .in -4n
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .in
39 .sp
40 .BR stpcpy ():
41 .PD 0
42 .ad l
43 .RS 4
44 .TP 4
45 Since glibc 2.10:
46 _XOPEN_SOURCE\ >=\ 700 || _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\\0\(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 .SS Multithreading (see pthreads(7))
73 The
74 .BR stpcpy ()
75 function is thread-safe.
76 .SH CONFORMING TO
77 This function was added to POSIX.1-2008.
78 Before that, it was not part of
79 the C or POSIX.1 standards, nor customary on UNIX systems.
80 It first appeared at least as early as 1986,
81 in the Lattice C AmigaDOS compiler,
82 then in the GNU fileutils and GNU textutils in 1989,
83 and in the GNU C library by 1992.
84 It is also present on the BSDs.
85 .SH BUGS
86 This function may overrun the buffer
87 .IR dest .
88 .SH EXAMPLE
89 For example, this program uses
90 .BR stpcpy ()
91 to concatenate
92 .B foo
93 and
94 .B bar
95 to produce
96 .BR foobar ,
97 which it then prints.
98 .nf
99
100 #define _GNU_SOURCE
101 #include <string.h>
102 #include <stdio.h>
103
104 int
105 main(void)
106 {
107     char buffer[20];
108     char *to = buffer;
109
110     to = stpcpy(to, "foo");
111     to = stpcpy(to, "bar");
112     printf("%s\\n", buffer);
113 }
114 .fi
115 .SH SEE ALSO
116 .BR bcopy (3),
117 .BR memccpy (3),
118 .BR memcpy (3),
119 .BR memmove (3),
120 .BR stpncpy (3),
121 .BR strcpy (3),
122 .BR string (3),
123 .BR wcpcpy (3)
124 .SH COLOPHON
125 This page is part of release 3.79 of the Linux
126 .I man-pages
127 project.
128 A description of the project,
129 information about reporting bugs,
130 and the latest version of this page,
131 can be found at
132 \%http://www.kernel.org/doc/man\-pages/.