]>
Commit | Line | Data |
---|---|---|
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 | .\" | |
822002bd | 25 | .TH STPCPY 3 2009-02-04 "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 | |
30 | .B #define _GNU_SOURCE | |
31 | .br | |
32 | .B #include <string.h> | |
33 | .sp | |
34 | .BI "char *stpcpy(char *" dest ", const char *" src ); | |
35 | .fi | |
36 | .SH DESCRIPTION | |
60a90ecd MK |
37 | The |
38 | .BR stpcpy () | |
39 | function copies the string pointed to by \fIsrc\fP | |
f81fb444 | 40 | (including the terminating \(aq\\0\(aq character) to the array pointed to by |
1c44bd5b MK |
41 | \fIdest\fP. |
42 | The strings may not overlap, and the destination string | |
fea681da MK |
43 | \fIdest\fP must be large enough to receive the copy. |
44 | .SH "RETURN VALUE" | |
60a90ecd MK |
45 | .BR stpcpy () |
46 | returns a pointer to the \fBend\fP of the string | |
28d88c17 | 47 | \fIdest\fP (that is, the address of the terminating null byte) |
fea681da | 48 | rather than the beginning. |
2b2581ee MK |
49 | .SH "CONFORMING TO" |
50 | This function is not part of the C or POSIX.1 standards, and is | |
51 | not customary on Unix systems, but is not a GNU invention either. | |
52 | Perhaps it comes from MS-DOS. | |
822002bd | 53 | Nowadays, it is also present on the BSDs. |
fea681da | 54 | .SH EXAMPLE |
60a90ecd MK |
55 | For example, this program uses |
56 | .BR stpcpy () | |
57 | to concatenate \fBfoo\fP and | |
fea681da | 58 | \fBbar\fP to produce \fBfoobar\fP, which it then prints. |
088a639b | 59 | .in +4n |
fea681da MK |
60 | .nf |
61 | ||
56e50303 | 62 | #define _GNU_SOURCE |
2b2581ee | 63 | #include <string.h> |
56e50303 | 64 | #include <stdio.h> |
fea681da | 65 | |
2b2581ee | 66 | int |
b6898014 | 67 | main(void) |
2b2581ee | 68 | { |
56e50303 | 69 | char buffer[20]; |
2b2581ee | 70 | char *to = buffer; |
56e50303 | 71 | |
2b2581ee MK |
72 | to = stpcpy(to, "foo"); |
73 | to = stpcpy(to, "bar"); | |
74 | printf("%s\\n", buffer); | |
75 | } | |
fea681da | 76 | .fi |
2b2581ee | 77 | .in |
34042be4 MK |
78 | .SH BUGS |
79 | This function may overrun the buffer | |
80 | .IR dest . | |
fea681da MK |
81 | .SH "SEE ALSO" |
82 | .BR bcopy (3), | |
83 | .BR memccpy (3), | |
84 | .BR memcpy (3), | |
85 | .BR memmove (3), | |
1709027c | 86 | .BR strcpy (3), |
d095200e | 87 | .BR string (3), |
0a90178c MK |
88 | .BR wcpcpy (3), |
89 | .BR feature_test_macros (7) |