]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stpcpy.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / stpcpy.3
CommitLineData
fea681da
MK
1.\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
97986708 25.TH STPCPY 3 2016-03-15 "GNU" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27stpcpy \- copy a string returning a pointer to its end
28.SH SYNOPSIS
29.nf
fea681da 30.B #include <string.h>
68e4db0a 31.PP
fea681da
MK
32.BI "char *stpcpy(char *" dest ", const char *" src );
33.fi
68e4db0a 34.PP
79247bb1
MK
35.in -4n
36Feature Test Macro Requirements for glibc (see
37.BR feature_test_macros (7)):
38.in
68e4db0a 39.PP
79247bb1 40.BR stpcpy ():
ea91c3fd
MK
41.PD 0
42.ad l
43.RS 4
44.TP 4
45Since glibc 2.10:
b0da7b8b 46_POSIX_C_SOURCE\ >=\ 200809L
ea91c3fd 47.TP
79247bb1
MK
48Before glibc 2.10:
49_GNU_SOURCE
ea91c3fd
MK
50.RE
51.ad
52.PD
fea681da 53.SH DESCRIPTION
60a90ecd
MK
54The
55.BR stpcpy ()
e4a0d6cb
MK
56function copies the string pointed to by
57.I src
71d9e7ae 58(including the terminating null byte (\(aq\\0\(aq)) to the array pointed to by
e4a0d6cb 59.IR dest .
1c44bd5b 60The strings may not overlap, and the destination string
e4a0d6cb
MK
61.I dest
62must be large enough to receive the copy.
47297adb 63.SH RETURN VALUE
60a90ecd 64.BR stpcpy ()
e4a0d6cb
MK
65returns a pointer to the
66.B end
67of the string
68.I dest
69(that is, the address of the terminating null byte)
fea681da 70rather than the beginning.
1a10d985 71.SH ATTRIBUTES
a6bc147c
PH
72For an explanation of the terms used in this section, see
73.BR attributes (7).
74.TS
75allbox;
76lb lb lb
77l l l.
78Interface Attribute Value
79T{
1a10d985 80.BR stpcpy ()
a6bc147c
PH
81T} Thread safety MT-Safe
82.TE
47297adb 83.SH CONFORMING TO
e3948c69
MK
84This function was added to POSIX.1-2008.
85Before that, it was not part of
b35fe3a0
IS
86the C or POSIX.1 standards, nor customary on UNIX systems.
87It first appeared at least as early as 1986,
88in the Lattice C AmigaDOS compiler,
89then in the GNU fileutils and GNU textutils in 1989,
d6780233 90and in the GNU C library by 1992.
4175f999 91It is also present on the BSDs.
22cb459d
MK
92.SH BUGS
93This function may overrun the buffer
94.IR dest .
fea681da 95.SH EXAMPLE
60a90ecd
MK
96For example, this program uses
97.BR stpcpy ()
e4a0d6cb
MK
98to concatenate
99.B foo
100and
101.B bar
102to produce
103.BR foobar ,
104which it then prints.
a2b7a144
MK
105.PP
106.EX
56e50303 107#define _GNU_SOURCE
2b2581ee 108#include <string.h>
56e50303 109#include <stdio.h>
fea681da 110
2b2581ee 111int
b6898014 112main(void)
2b2581ee 113{
56e50303 114 char buffer[20];
2b2581ee 115 char *to = buffer;
56e50303 116
2b2581ee
MK
117 to = stpcpy(to, "foo");
118 to = stpcpy(to, "bar");
119 printf("%s\\n", buffer);
120}
a2b7a144 121.EE
47297adb 122.SH SEE ALSO
fea681da
MK
123.BR bcopy (3),
124.BR memccpy (3),
125.BR memcpy (3),
126.BR memmove (3),
268a3684 127.BR stpncpy (3),
1709027c 128.BR strcpy (3),
d095200e 129.BR string (3),
0a4f8b7b 130.BR wcpcpy (3)