OSDN Git Service

83260dfd464fba973acfc5d2274d83bfb6aa9986
[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  2012-03-15 "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 CONFORMING TO
72 This function was added to POSIX.1-2008.
73 Before that, it was not part of
74 the C or POSIX.1 standards, nor customary on UNIX systems, but was not a
75 GNU invention either.
76 Perhaps it came from MS-DOS.
77 It is also present on the BSDs.
78 .SH BUGS
79 This function may overrun the buffer
80 .IR dest .
81 .SH EXAMPLE
82 For example, this program uses
83 .BR stpcpy ()
84 to concatenate
85 .B foo
86 and
87 .B bar
88 to produce
89 .BR foobar ,
90 which it then prints.
91 .in +4n
92 .nf
93
94 #define _GNU_SOURCE
95 #include <string.h>
96 #include <stdio.h>
97
98 int
99 main(void)
100 {
101     char buffer[20];
102     char *to = buffer;
103
104     to = stpcpy(to, "foo");
105     to = stpcpy(to, "bar");
106     printf("%s\\n", buffer);
107 }
108 .fi
109 .in
110 .SH SEE ALSO
111 .BR bcopy (3),
112 .BR memccpy (3),
113 .BR memcpy (3),
114 .BR memmove (3),
115 .BR stpncpy (3),
116 .BR strcpy (3),
117 .BR string (3),
118 .BR wcpcpy (3)