]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stpcpy.3
stpncpy.3: Reformat thread-safety information
[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.\"
726663fd 25.TH STPCPY 3 2014-05-10 "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
MK
30.B #include <string.h>
31.sp
32.BI "char *stpcpy(char *" dest ", const char *" src );
33.fi
79247bb1
MK
34.sp
35.in -4n
36Feature Test Macro Requirements for glibc (see
37.BR feature_test_macros (7)):
38.in
39.sp
40.BR stpcpy ():
ea91c3fd
MK
41.PD 0
42.ad l
43.RS 4
44.TP 4
45Since glibc 2.10:
46_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
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
PH
71.SH ATTRIBUTES
72.SS Multithreading (see pthreads(7))
73The
74.BR stpcpy ()
75function is thread-safe.
47297adb 76.SH CONFORMING TO
e3948c69
MK
77This function was added to POSIX.1-2008.
78Before that, it was not part of
b35fe3a0
IS
79the C or POSIX.1 standards, nor customary on UNIX systems.
80It first appeared at least as early as 1986,
81in the Lattice C AmigaDOS compiler,
82then in the GNU fileutils and GNU textutils in 1989,
d6780233 83and in the GNU C library by 1992.
4175f999 84It is also present on the BSDs.
22cb459d
MK
85.SH BUGS
86This function may overrun the buffer
87.IR dest .
fea681da 88.SH EXAMPLE
60a90ecd
MK
89For example, this program uses
90.BR stpcpy ()
e4a0d6cb
MK
91to concatenate
92.B foo
93and
94.B bar
95to produce
96.BR foobar ,
97which it then prints.
fea681da
MK
98.nf
99
56e50303 100#define _GNU_SOURCE
2b2581ee 101#include <string.h>
56e50303 102#include <stdio.h>
fea681da 103
2b2581ee 104int
b6898014 105main(void)
2b2581ee 106{
56e50303 107 char buffer[20];
2b2581ee 108 char *to = buffer;
56e50303 109
2b2581ee
MK
110 to = stpcpy(to, "foo");
111 to = stpcpy(to, "bar");
112 printf("%s\\n", buffer);
113}
fea681da 114.fi
47297adb 115.SH SEE ALSO
fea681da
MK
116.BR bcopy (3),
117.BR memccpy (3),
118.BR memcpy (3),
119.BR memmove (3),
268a3684 120.BR stpncpy (3),
1709027c 121.BR strcpy (3),
d095200e 122.BR string (3),
0a4f8b7b 123.BR wcpcpy (3)