2004-11-03 13:51:07 +00:00
|
|
|
.\" Hey Emacs! This file is -*- nroff -*- source.
|
|
|
|
.\"
|
|
|
|
.\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
gets.3, mbtowc.3, printf.3, puts.3, scanf.3, stpcpy.3, stpncpy.3, strcat.3, strlen.3, strnlen.3, strsep.3, strstr.3, strxfrm.3, utmp.5: Global fix: consistent use of "null byte"
Bring more consistency to the discussion of
"[terminating] null byte"
by writing (at least in the initial use in a page)
"[terminating] null byte ('\0')".
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-09-28 04:16:17 +00:00
|
|
|
.TH STPCPY 3 2011-09-28 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
stpcpy \- copy a string returning a pointer to its end
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <string.h>
|
|
|
|
.sp
|
|
|
|
.BI "char *stpcpy(char *" dest ", const char *" src );
|
|
|
|
.fi
|
2010-09-15 07:05:46 +00:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.BR stpcpy ():
|
faccessat.2, dprintf.3, fexecve.3, fmemopen.3, mbsnrtowcs.3, mkfifoat.3, opendir.3, stpcpy.3, stpncpy.3, strnlen.3, strsignal.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 16:57:10 +00:00
|
|
|
.PD 0
|
|
|
|
.ad l
|
|
|
|
.RS 4
|
|
|
|
.TP 4
|
|
|
|
Since glibc 2.10:
|
|
|
|
_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
|
|
|
|
.TP
|
2010-09-15 07:05:46 +00:00
|
|
|
Before glibc 2.10:
|
|
|
|
_GNU_SOURCE
|
faccessat.2, dprintf.3, fexecve.3, fmemopen.3, mbsnrtowcs.3, mkfifoat.3, opendir.3, stpcpy.3, stpncpy.3, strnlen.3, strsignal.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 16:57:10 +00:00
|
|
|
.RE
|
|
|
|
.ad
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
2007-05-12 09:06:04 +00:00
|
|
|
The
|
|
|
|
.BR stpcpy ()
|
|
|
|
function copies the string pointed to by \fIsrc\fP
|
gets.3, mbtowc.3, printf.3, puts.3, scanf.3, stpcpy.3, stpncpy.3, strcat.3, strlen.3, strnlen.3, strsep.3, strstr.3, strxfrm.3, utmp.5: Global fix: consistent use of "null byte"
Bring more consistency to the discussion of
"[terminating] null byte"
by writing (at least in the initial use in a page)
"[terminating] null byte ('\0')".
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-09-28 04:16:17 +00:00
|
|
|
(including the terminating null byte (\(aq\\0\(aq)) to the array pointed to by
|
2007-04-24 16:44:51 +00:00
|
|
|
\fIdest\fP.
|
|
|
|
The strings may not overlap, and the destination string
|
2004-11-03 13:51:07 +00:00
|
|
|
\fIdest\fP must be large enough to receive the copy.
|
|
|
|
.SH "RETURN VALUE"
|
2007-05-12 09:06:04 +00:00
|
|
|
.BR stpcpy ()
|
|
|
|
returns a pointer to the \fBend\fP of the string
|
2006-01-13 02:09:44 +00:00
|
|
|
\fIdest\fP (that is, the address of the terminating null byte)
|
2004-11-03 13:51:07 +00:00
|
|
|
rather than the beginning.
|
2007-05-19 04:30:20 +00:00
|
|
|
.SH "CONFORMING TO"
|
2011-09-29 04:24:34 +00:00
|
|
|
This function was added to POSIX.1-2008. Before that, it was not part of
|
|
|
|
the C or POSIX.1 standards, nor customary on UNIX systems, but was not a
|
|
|
|
GNU invention either. Perhaps it came from MS-DOS. It is also present on
|
|
|
|
the BSDs.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH EXAMPLE
|
2007-05-12 09:06:04 +00:00
|
|
|
For example, this program uses
|
|
|
|
.BR stpcpy ()
|
|
|
|
to concatenate \fBfoo\fP and
|
2004-11-03 13:51:07 +00:00
|
|
|
\fBbar\fP to produce \fBfoobar\fP, which it then prints.
|
2007-12-19 06:57:44 +00:00
|
|
|
.in +4n
|
2004-11-03 13:51:07 +00:00
|
|
|
.nf
|
|
|
|
|
2009-02-02 21:25:32 +00:00
|
|
|
#define _GNU_SOURCE
|
2007-05-19 04:30:20 +00:00
|
|
|
#include <string.h>
|
2009-02-02 21:25:32 +00:00
|
|
|
#include <stdio.h>
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2007-05-19 04:30:20 +00:00
|
|
|
int
|
2009-02-02 21:21:05 +00:00
|
|
|
main(void)
|
2007-05-19 04:30:20 +00:00
|
|
|
{
|
2009-02-02 21:25:32 +00:00
|
|
|
char buffer[20];
|
2007-05-19 04:30:20 +00:00
|
|
|
char *to = buffer;
|
2009-02-02 21:25:32 +00:00
|
|
|
|
2007-05-19 04:30:20 +00:00
|
|
|
to = stpcpy(to, "foo");
|
|
|
|
to = stpcpy(to, "bar");
|
|
|
|
printf("%s\\n", buffer);
|
|
|
|
}
|
2004-11-03 13:51:07 +00:00
|
|
|
.fi
|
2007-05-19 04:30:20 +00:00
|
|
|
.in
|
2009-02-02 21:27:11 +00:00
|
|
|
.SH BUGS
|
|
|
|
This function may overrun the buffer
|
|
|
|
.IR dest .
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR bcopy (3),
|
|
|
|
.BR memccpy (3),
|
|
|
|
.BR memcpy (3),
|
|
|
|
.BR memmove (3),
|
2011-09-29 04:24:34 +00:00
|
|
|
.BR stpncpy (3),
|
2006-02-09 20:57:44 +00:00
|
|
|
.BR strcpy (3),
|
index.3, stpcpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strfry.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtok.3, strxfrm.3: SEE ALSO: Add reference to string(3)
The idea here is to provide a route to discover other
string functions.
Reported-by: Mark Hills <mark@pogo.org.uk>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-12 14:39:58 +00:00
|
|
|
.BR string (3),
|
getresuid.2, intro.2, mremap.2, open.2, poll.2, posix_fadvise.2, pread.2, remap_file_pages.2, setresuid.2, signal.2, splice.2, sync_file_range.2, tee.2, vmsplice.2, INFINITY.3, asprintf.3, assert_perror.3, basename.3, bsd_signal.3, canonicalize_file_name.3, clog10.3, crypt.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, encrypt.3, exp10.3, fcloseall.3, fenv.3, ffs.3, fmemopen.3, fopencookie.3, ftw.3, getdate.3, getline.3, getloadavg.3, getopt.3, getsubopt.3, getutent.3, grantpt.3, hsearch.3, intro.3, lseek64.3, memmem.3, mempcpy.3, mq_receive.3, mq_send.3, posix_fallocate.3, pow10.3, program_invocation_name.3, ptsname.3, putgrent.3, readdir.3, sigset.3, sincos.3, stpcpy.3, stpncpy.3, strchr.3, strfry.3, strnlen.3, strptime.3, strsignal.3, strstr.3, strverscmp.3, swab.3, sysv_signal.3, tsearch.3, unlocked_stdio.3, unlockpt.3, wcpcpy.3, wcpncpy.3, wcsdup.3, wcwidth.3: SEE ALSO: Remove redundant reference to feature_test_macros(7)
Reported-by: Florian Lehmann <flo.lehmann@googlemail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-31 05:05:22 +00:00
|
|
|
.BR wcpcpy (3)
|