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