Commit | Line | Data |
---|---|---|
ae59e04c | 1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. |
657bdb9b KB |
2 | .\" All rights reserved. |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" Chris Torek. | |
657bdb9b KB |
6 | .\" %sccs.include.redist.man% |
7 | .\" | |
ae59e04c | 8 | .\" @(#)strcpy.3 5.3 (Berkeley) %G% |
657bdb9b | 9 | .\" |
ae59e04c CL |
10 | .Dd |
11 | .Dt STRCPY 3 | |
12 | .Os BSD 4 | |
13 | .Sh NAME | |
14 | .Nm strcpy | |
15 | .Nd copy strings | |
16 | .Sh SYNOPSIS | |
17 | .Fd #include <string.h> | |
18 | .Ft char * | |
19 | .Fn strcpy "char *dst" "const char *src" | |
20 | .Ft char * | |
21 | .Fn strncpy "char *dst" "const char *src" "size_t len" | |
22 | .Sh DESCRIPTION | |
23 | The | |
24 | .Fn strcpy | |
ee7c1421 | 25 | and |
ae59e04c CL |
26 | .Fn strncpy |
27 | functions | |
28 | copy the string | |
29 | .Fa src | |
657bdb9b | 30 | to |
ae59e04c CL |
31 | .Fa dst |
32 | (including the terminating | |
33 | .Ql \e0 | |
34 | character). | |
35 | .Pp | |
36 | The | |
37 | .Fn strncpy | |
38 | copies not more than | |
39 | .Fa len | |
ee7c1421 | 40 | characters into |
ae59e04c CL |
41 | .Fa dst , |
42 | appending | |
43 | .Ql \e0 | |
44 | characters if | |
45 | .Fa src | |
ee7c1421 | 46 | is less than |
ae59e04c | 47 | .Fa len |
ee7c1421 | 48 | characters long, and |
ae59e04c | 49 | .Em not |
ee7c1421 | 50 | terminating |
ae59e04c | 51 | .Fa dst |
ee7c1421 | 52 | if |
ae59e04c | 53 | .Fa src |
ee7c1421 | 54 | is more than |
ae59e04c | 55 | .Fa len |
ee7c1421 | 56 | characters long. |
ae59e04c CL |
57 | .Sh RETURN VALUES |
58 | The | |
59 | .Fn strcpy | |
ee7c1421 | 60 | and |
ae59e04c CL |
61 | .Fn strncpy |
62 | functions | |
ee7c1421 | 63 | return |
ae59e04c CL |
64 | .Fa dst . |
65 | .Sh EXAMPLES | |
66 | The following sets | |
67 | .Dq Li chararray | |
68 | to | |
69 | .Dq Li abc\e0\e0\e0 : | |
70 | .Bd -literal -offset indent | |
ee7c1421 | 71 | (void)strncpy(chararray, "abc", 6). |
ae59e04c CL |
72 | .Ed |
73 | .Pp | |
74 | The following sets | |
75 | .Dq Li chararray | |
76 | to | |
77 | .Dq Li abcdef : | |
78 | .Bd -literal -offset indent | |
ee7c1421 | 79 | (void)strncpy(chararray, "abcdefgh", 6); |
ae59e04c CL |
80 | .Ed |
81 | .Sh SEE ALSO | |
82 | .Xr bcopy 3 , | |
83 | .Xr memccpy 3 , | |
84 | .Xr memcpy 3 , | |
85 | .Xr memmove 3 | |
86 | .Sh STANDARDS | |
87 | The | |
88 | .Fn strcpy | |
ee7c1421 | 89 | and |
ae59e04c CL |
90 | .Fn strncpy |
91 | functions | |
92 | conform to | |
93 | .St -ansiC . |