OSDN Git Service

(split) LDP: Update original to LDP v3.65
[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-01-13 "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, but was not a
80 GNU invention either.
81 Perhaps it came from MS-DOS.
82 It is also present on the BSDs.
83 .SH BUGS
84 This function may overrun the buffer
85 .IR dest .
86 .SH EXAMPLE
87 For example, this program uses
88 .BR stpcpy ()
89 to concatenate
90 .B foo
91 and
92 .B bar
93 to produce
94 .BR foobar ,
95 which it then prints.
96 .nf
97
98 #define _GNU_SOURCE
99 #include <string.h>
100 #include <stdio.h>
101
102 int
103 main(void)
104 {
105     char buffer[20];
106     char *to = buffer;
107
108     to = stpcpy(to, "foo");
109     to = stpcpy(to, "bar");
110     printf("%s\\n", buffer);
111 }
112 .fi
113 .SH SEE ALSO
114 .BR bcopy (3),
115 .BR memccpy (3),
116 .BR memcpy (3),
117 .BR memmove (3),
118 .BR stpncpy (3),
119 .BR strcpy (3),
120 .BR string (3),
121 .BR wcpcpy (3)
122 .SH COLOPHON
123 This page is part of release 3.65 of the Linux
124 .I man-pages
125 project.
126 A description of the project,
127 and information about reporting bugs,
128 can be found at
129 \%http://www.kernel.org/doc/man\-pages/.