]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stpcpy.3
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man3 / stpcpy.3
CommitLineData
fea681da
MK
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.
c13182ef 13.\"
fea681da
MK
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.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
22cb459d 25.TH STPCPY 3 2012-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
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 ()
56function copies the string pointed to by \fIsrc\fP
71d9e7ae 57(including the terminating null byte (\(aq\\0\(aq)) to the array pointed to by
1c44bd5b
MK
58\fIdest\fP.
59The strings may not overlap, and the destination string
fea681da 60\fIdest\fP must be large enough to receive the copy.
47297adb 61.SH RETURN VALUE
60a90ecd
MK
62.BR stpcpy ()
63returns a pointer to the \fBend\fP of the string
28d88c17 64\fIdest\fP (that is, the address of the terminating null byte)
fea681da 65rather than the beginning.
47297adb 66.SH CONFORMING TO
268a3684
MF
67This function was added to POSIX.1-2008. Before that, it was not part of
68the C or POSIX.1 standards, nor customary on UNIX systems, but was not a
4175f999
MK
69GNU invention either.
70Perhaps it came from MS-DOS.
71It is also present on the BSDs.
22cb459d
MK
72.SH BUGS
73This function may overrun the buffer
74.IR dest .
fea681da 75.SH EXAMPLE
60a90ecd
MK
76For example, this program uses
77.BR stpcpy ()
78to concatenate \fBfoo\fP and
fea681da 79\fBbar\fP to produce \fBfoobar\fP, which it then prints.
088a639b 80.in +4n
fea681da
MK
81.nf
82
56e50303 83#define _GNU_SOURCE
2b2581ee 84#include <string.h>
56e50303 85#include <stdio.h>
fea681da 86
2b2581ee 87int
b6898014 88main(void)
2b2581ee 89{
56e50303 90 char buffer[20];
2b2581ee 91 char *to = buffer;
56e50303 92
2b2581ee
MK
93 to = stpcpy(to, "foo");
94 to = stpcpy(to, "bar");
95 printf("%s\\n", buffer);
96}
fea681da 97.fi
2b2581ee 98.in
47297adb 99.SH SEE ALSO
fea681da
MK
100.BR bcopy (3),
101.BR memccpy (3),
102.BR memcpy (3),
103.BR memmove (3),
268a3684 104.BR stpncpy (3),
1709027c 105.BR strcpy (3),
d095200e 106.BR string (3),
0a4f8b7b 107.BR wcpcpy (3)