OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[linuxjm/LDP_man-pages.git] / original / man3 / stpcpy.3
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
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 \fIsrc\fP
57 (including the terminating null byte (\(aq\\0\(aq)) to the array pointed to by
58 \fIdest\fP.
59 The strings may not overlap, and the destination string
60 \fIdest\fP must be large enough to receive the copy.
61 .SH "RETURN VALUE"
62 .BR stpcpy ()
63 returns a pointer to the \fBend\fP of the string
64 \fIdest\fP (that is, the address of the terminating null byte)
65 rather than the beginning.
66 .SH "CONFORMING TO"
67 This function was added to POSIX.1-2008. Before that, it was not part of
68 the C or POSIX.1 standards, nor customary on UNIX systems, but was not a
69 GNU invention either. Perhaps it came from MS-DOS. It is also present on
70 the BSDs.
71 .SH BUGS
72 This function may overrun the buffer
73 .IR dest .
74 .SH EXAMPLE
75 For example, this program uses
76 .BR stpcpy ()
77 to concatenate \fBfoo\fP and
78 \fBbar\fP to produce \fBfoobar\fP, which it then prints.
79 .in +4n
80 .nf
81
82 #define _GNU_SOURCE
83 #include <string.h>
84 #include <stdio.h>
85
86 int
87 main(void)
88 {
89     char buffer[20];
90     char *to = buffer;
91
92     to = stpcpy(to, "foo");
93     to = stpcpy(to, "bar");
94     printf("%s\\n", buffer);
95 }
96 .fi
97 .in
98 .SH "SEE ALSO"
99 .BR bcopy (3),
100 .BR memccpy (3),
101 .BR memcpy (3),
102 .BR memmove (3),
103 .BR stpncpy (3),
104 .BR strcpy (3),
105 .BR string (3),
106 .BR wcpcpy (3)