]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com> |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da | 4 | .\" |
45186a5d | 5 | .TH STPCPY 3 2021-03-22 "Linux man-pages (unreleased)" |
fea681da MK |
6 | .SH NAME |
7 | stpcpy \- copy a string returning a pointer to its end | |
395b371f AC |
8 | .SH LIBRARY |
9 | Standard C library | |
8fc3b2cf | 10 | .RI ( libc ", " \-lc ) |
fea681da MK |
11 | .SH SYNOPSIS |
12 | .nf | |
fea681da | 13 | .B #include <string.h> |
68e4db0a | 14 | .PP |
f23eb1ff | 15 | .BI "char *stpcpy(char *restrict " dest ", const char *restrict " src ); |
fea681da | 16 | .fi |
68e4db0a | 17 | .PP |
d39ad78f | 18 | .RS -4 |
79247bb1 MK |
19 | Feature Test Macro Requirements for glibc (see |
20 | .BR feature_test_macros (7)): | |
d39ad78f | 21 | .RE |
68e4db0a | 22 | .PP |
79247bb1 | 23 | .BR stpcpy (): |
9d2adbae MK |
24 | .nf |
25 | Since glibc 2.10: | |
5c10d2c5 | 26 | _POSIX_C_SOURCE >= 200809L |
9d2adbae MK |
27 | Before glibc 2.10: |
28 | _GNU_SOURCE | |
29 | .fi | |
fea681da | 30 | .SH DESCRIPTION |
60a90ecd MK |
31 | The |
32 | .BR stpcpy () | |
e4a0d6cb MK |
33 | function copies the string pointed to by |
34 | .I src | |
d1a71985 | 35 | (including the terminating null byte (\(aq\e0\(aq)) to the array pointed to by |
e4a0d6cb | 36 | .IR dest . |
1c44bd5b | 37 | The strings may not overlap, and the destination string |
e4a0d6cb MK |
38 | .I dest |
39 | must be large enough to receive the copy. | |
47297adb | 40 | .SH RETURN VALUE |
60a90ecd | 41 | .BR stpcpy () |
e4a0d6cb MK |
42 | returns a pointer to the |
43 | .B end | |
44 | of the string | |
45 | .I dest | |
46 | (that is, the address of the terminating null byte) | |
fea681da | 47 | rather than the beginning. |
1a10d985 | 48 | .SH ATTRIBUTES |
a6bc147c PH |
49 | For an explanation of the terms used in this section, see |
50 | .BR attributes (7). | |
c466875e MK |
51 | .ad l |
52 | .nh | |
a6bc147c PH |
53 | .TS |
54 | allbox; | |
c466875e | 55 | lbx lb lb |
a6bc147c PH |
56 | l l l. |
57 | Interface Attribute Value | |
58 | T{ | |
1a10d985 | 59 | .BR stpcpy () |
a6bc147c PH |
60 | T} Thread safety MT-Safe |
61 | .TE | |
c466875e MK |
62 | .hy |
63 | .ad | |
64 | .sp 1 | |
3113c7f3 | 65 | .SH STANDARDS |
e3948c69 MK |
66 | This function was added to POSIX.1-2008. |
67 | Before that, it was not part of | |
b35fe3a0 IS |
68 | the C or POSIX.1 standards, nor customary on UNIX systems. |
69 | It first appeared at least as early as 1986, | |
70 | in the Lattice C AmigaDOS compiler, | |
71 | then in the GNU fileutils and GNU textutils in 1989, | |
d6780233 | 72 | and in the GNU C library by 1992. |
4175f999 | 73 | It is also present on the BSDs. |
22cb459d MK |
74 | .SH BUGS |
75 | This function may overrun the buffer | |
76 | .IR dest . | |
a14af333 | 77 | .SH EXAMPLES |
60a90ecd MK |
78 | For example, this program uses |
79 | .BR stpcpy () | |
e4a0d6cb MK |
80 | to concatenate |
81 | .B foo | |
82 | and | |
83 | .B bar | |
84 | to produce | |
85 | .BR foobar , | |
86 | which it then prints. | |
a2b7a144 MK |
87 | .PP |
88 | .EX | |
56e50303 | 89 | #define _GNU_SOURCE |
2b2581ee | 90 | #include <string.h> |
56e50303 | 91 | #include <stdio.h> |
fea681da | 92 | |
2b2581ee | 93 | int |
b6898014 | 94 | main(void) |
2b2581ee | 95 | { |
56e50303 | 96 | char buffer[20]; |
2b2581ee | 97 | char *to = buffer; |
56e50303 | 98 | |
2b2581ee MK |
99 | to = stpcpy(to, "foo"); |
100 | to = stpcpy(to, "bar"); | |
d1a71985 | 101 | printf("%s\en", buffer); |
2b2581ee | 102 | } |
a2b7a144 | 103 | .EE |
47297adb | 104 | .SH SEE ALSO |
fea681da MK |
105 | .BR bcopy (3), |
106 | .BR memccpy (3), | |
107 | .BR memcpy (3), | |
108 | .BR memmove (3), | |
268a3684 | 109 | .BR stpncpy (3), |
1709027c | 110 | .BR strcpy (3), |
d095200e | 111 | .BR string (3), |
0a4f8b7b | 112 | .BR wcpcpy (3) |