]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stpcpy.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / stpcpy.3
CommitLineData
fea681da
MK
1.\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da 4.\"
45186a5d 5.TH STPCPY 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
6.SH NAME
7stpcpy \- copy a string returning a pointer to its end
395b371f
AC
8.SH LIBRARY
9Standard C library
8fc3b2cf 10.RI ( libc ", " \-lc )
fea681da
MK
11.SH SYNOPSIS
12.nf
fea681da 13.B #include <string.h>
68e4db0a 14.PP
f23eb1ff 15.BI "char *stpcpy(char *restrict " dest ", const char *restrict " src );
fea681da 16.fi
68e4db0a 17.PP
d39ad78f 18.RS -4
79247bb1
MK
19Feature Test Macro Requirements for glibc (see
20.BR feature_test_macros (7)):
d39ad78f 21.RE
68e4db0a 22.PP
79247bb1 23.BR stpcpy ():
9d2adbae
MK
24.nf
25 Since glibc 2.10:
5c10d2c5 26 _POSIX_C_SOURCE >= 200809L
9d2adbae
MK
27 Before glibc 2.10:
28 _GNU_SOURCE
29.fi
fea681da 30.SH DESCRIPTION
60a90ecd
MK
31The
32.BR stpcpy ()
e4a0d6cb
MK
33function copies the string pointed to by
34.I src
d1a71985 35(including the terminating null byte (\(aq\e0\(aq)) to the array pointed to by
e4a0d6cb 36.IR dest .
1c44bd5b 37The strings may not overlap, and the destination string
e4a0d6cb
MK
38.I dest
39must be large enough to receive the copy.
47297adb 40.SH RETURN VALUE
60a90ecd 41.BR stpcpy ()
e4a0d6cb
MK
42returns a pointer to the
43.B end
44of the string
45.I dest
46(that is, the address of the terminating null byte)
fea681da 47rather than the beginning.
1a10d985 48.SH ATTRIBUTES
a6bc147c
PH
49For an explanation of the terms used in this section, see
50.BR attributes (7).
c466875e
MK
51.ad l
52.nh
a6bc147c
PH
53.TS
54allbox;
c466875e 55lbx lb lb
a6bc147c
PH
56l l l.
57Interface Attribute Value
58T{
1a10d985 59.BR stpcpy ()
a6bc147c
PH
60T} Thread safety MT-Safe
61.TE
c466875e
MK
62.hy
63.ad
64.sp 1
3113c7f3 65.SH STANDARDS
e3948c69
MK
66This function was added to POSIX.1-2008.
67Before that, it was not part of
b35fe3a0
IS
68the C or POSIX.1 standards, nor customary on UNIX systems.
69It first appeared at least as early as 1986,
70in the Lattice C AmigaDOS compiler,
71then in the GNU fileutils and GNU textutils in 1989,
d6780233 72and in the GNU C library by 1992.
4175f999 73It is also present on the BSDs.
22cb459d
MK
74.SH BUGS
75This function may overrun the buffer
76.IR dest .
a14af333 77.SH EXAMPLES
60a90ecd
MK
78For example, this program uses
79.BR stpcpy ()
e4a0d6cb
MK
80to concatenate
81.B foo
82and
83.B bar
84to produce
85.BR foobar ,
86which it then prints.
a2b7a144
MK
87.PP
88.EX
56e50303 89#define _GNU_SOURCE
2b2581ee 90#include <string.h>
56e50303 91#include <stdio.h>
fea681da 92
2b2581ee 93int
b6898014 94main(void)
2b2581ee 95{
56e50303 96 char buffer[20];
2b2581ee 97 char *to = buffer;
56e50303 98
2b2581ee
MK
99 to = stpcpy(to, "foo");
100 to = stpcpy(to, "bar");
d1a71985 101 printf("%s\en", buffer);
2b2581ee 102}
a2b7a144 103.EE
47297adb 104.SH SEE ALSO
fea681da
MK
105.BR bcopy (3),
106.BR memccpy (3),
107.BR memcpy (3),
108.BR memmove (3),
268a3684 109.BR stpncpy (3),
1709027c 110.BR strcpy (3),
d095200e 111.BR string (3),
0a4f8b7b 112.BR wcpcpy (3)