Blame man3/stpcpy.3

Packit 7cfc04
.\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of this
Packit 7cfc04
.\" manual under the conditions for verbatim copying, provided that the
Packit 7cfc04
.\" entire resulting derived work is distributed under the terms of a
Packit 7cfc04
.\" permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 7cfc04
.\" responsibility for errors or omissions, or for damages resulting from
Packit 7cfc04
.\" the use of the information contained herein.  The author(s) may not
Packit 7cfc04
.\" have taken the same level of care in the production of this manual,
Packit 7cfc04
.\" which is licensed free of charge, as they might when working
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.TH STPCPY 3  2016-03-15 "GNU" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
stpcpy \- copy a string returning a pointer to its end
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <string.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "char *stpcpy(char *" dest ", const char *" src );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.BR stpcpy ():
Packit 7cfc04
.PD 0
Packit 7cfc04
.ad l
Packit 7cfc04
.RS 4
Packit 7cfc04
.TP 4
Packit 7cfc04
Since glibc 2.10:
Packit 7cfc04
_POSIX_C_SOURCE\ >=\ 200809L
Packit 7cfc04
.TP
Packit 7cfc04
Before glibc 2.10:
Packit 7cfc04
_GNU_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.ad
Packit 7cfc04
.PD
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.BR stpcpy ()
Packit 7cfc04
function copies the string pointed to by
Packit 7cfc04
.I src
Packit 7cfc04
(including the terminating null byte (\(aq\\0\(aq)) to the array pointed to by
Packit 7cfc04
.IR dest .
Packit 7cfc04
The strings may not overlap, and the destination string
Packit 7cfc04
.I dest
Packit 7cfc04
must be large enough to receive the copy.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
.BR stpcpy ()
Packit 7cfc04
returns a pointer to the
Packit 7cfc04
.B end
Packit 7cfc04
of the string
Packit 7cfc04
.I dest
Packit 7cfc04
(that is, the address of the terminating null byte)
Packit 7cfc04
rather than the beginning.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lb lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR stpcpy ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
This function was added to POSIX.1-2008.
Packit 7cfc04
Before that, it was not part of
Packit 7cfc04
the C or POSIX.1 standards, nor customary on UNIX systems.
Packit 7cfc04
It first appeared at least as early as 1986,
Packit 7cfc04
in the Lattice C AmigaDOS compiler,
Packit 7cfc04
then in the GNU fileutils and GNU textutils in 1989,
Packit 7cfc04
and in the GNU C library by 1992.
Packit 7cfc04
It is also present on the BSDs.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
This function may overrun the buffer
Packit 7cfc04
.IR dest .
Packit 7cfc04
.SH EXAMPLE
Packit 7cfc04
For example, this program uses
Packit 7cfc04
.BR stpcpy ()
Packit 7cfc04
to concatenate
Packit 7cfc04
.B foo
Packit 7cfc04
and
Packit 7cfc04
.B bar
Packit 7cfc04
to produce
Packit 7cfc04
.BR foobar ,
Packit 7cfc04
which it then prints.
Packit 7cfc04
.PP
Packit 7cfc04
.EX
Packit 7cfc04
#define _GNU_SOURCE
Packit 7cfc04
#include <string.h>
Packit 7cfc04
#include <stdio.h>
Packit 7cfc04
Packit 7cfc04
int
Packit 7cfc04
main(void)
Packit 7cfc04
{
Packit 7cfc04
    char buffer[20];
Packit 7cfc04
    char *to = buffer;
Packit 7cfc04
Packit 7cfc04
    to = stpcpy(to, "foo");
Packit 7cfc04
    to = stpcpy(to, "bar");
Packit 7cfc04
    printf("%s\\n", buffer);
Packit 7cfc04
}
Packit 7cfc04
.EE
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR bcopy (3),
Packit 7cfc04
.BR memccpy (3),
Packit 7cfc04
.BR memcpy (3),
Packit 7cfc04
.BR memmove (3),
Packit 7cfc04
.BR stpncpy (3),
Packit 7cfc04
.BR strcpy (3),
Packit 7cfc04
.BR string (3),
Packit 7cfc04
.BR wcpcpy (3)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.