]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/stpcpy.3
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getprior...
[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.\"
79247bb1 25.TH STPCPY 3 2010-09-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
f81fb444 57(including the terminating \(aq\\0\(aq character) to the array pointed to by
1c44bd5b
MK
58\fIdest\fP.
59The strings may not overlap, and the destination string
fea681da
MK
60\fIdest\fP must be large enough to receive the copy.
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.
2b2581ee
MK
66.SH "CONFORMING TO"
67This function is not part of the C or POSIX.1 standards, and is
008f1ecc 68not customary on UNIX systems, but is not a GNU invention either.
2b2581ee 69Perhaps it comes from MS-DOS.
822002bd 70Nowadays, it is also present on the BSDs.
fea681da 71.SH EXAMPLE
60a90ecd
MK
72For example, this program uses
73.BR stpcpy ()
74to concatenate \fBfoo\fP and
fea681da 75\fBbar\fP to produce \fBfoobar\fP, which it then prints.
088a639b 76.in +4n
fea681da
MK
77.nf
78
56e50303 79#define _GNU_SOURCE
2b2581ee 80#include <string.h>
56e50303 81#include <stdio.h>
fea681da 82
2b2581ee 83int
b6898014 84main(void)
2b2581ee 85{
56e50303 86 char buffer[20];
2b2581ee 87 char *to = buffer;
56e50303 88
2b2581ee
MK
89 to = stpcpy(to, "foo");
90 to = stpcpy(to, "bar");
91 printf("%s\\n", buffer);
92}
fea681da 93.fi
2b2581ee 94.in
34042be4
MK
95.SH BUGS
96This function may overrun the buffer
97.IR dest .
fea681da
MK
98.SH "SEE ALSO"
99.BR bcopy (3),
100.BR memccpy (3),
101.BR memcpy (3),
102.BR memmove (3),
1709027c 103.BR strcpy (3),
d095200e 104.BR string (3),
0a90178c
MK
105.BR wcpcpy (3),
106.BR feature_test_macros (7)