]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com> |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
22cb459d | 25 | .TH STPCPY 3 2012-03-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
26 | .SH NAME |
27 | stpcpy \- 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 | |
36 | Feature 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 | |
45 | Since glibc 2.10: | |
46 | _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L | |
47 | .TP | |
79247bb1 MK |
48 | Before glibc 2.10: |
49 | _GNU_SOURCE | |
ea91c3fd MK |
50 | .RE |
51 | .ad | |
52 | .PD | |
fea681da | 53 | .SH DESCRIPTION |
60a90ecd MK |
54 | The |
55 | .BR stpcpy () | |
56 | function 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. |
59 | The 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 () |
63 | returns a pointer to the \fBend\fP of the string | |
28d88c17 | 64 | \fIdest\fP (that is, the address of the terminating null byte) |
fea681da | 65 | rather than the beginning. |
47297adb | 66 | .SH CONFORMING TO |
268a3684 MF |
67 | This function was added to POSIX.1-2008. Before that, it was not part of |
68 | the C or POSIX.1 standards, nor customary on UNIX systems, but was not a | |
4175f999 MK |
69 | GNU invention either. |
70 | Perhaps it came from MS-DOS. | |
71 | It is also present on the BSDs. | |
22cb459d MK |
72 | .SH BUGS |
73 | This function may overrun the buffer | |
74 | .IR dest . | |
fea681da | 75 | .SH EXAMPLE |
60a90ecd MK |
76 | For example, this program uses |
77 | .BR stpcpy () | |
78 | to 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 | 87 | int |
b6898014 | 88 | main(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) |