xref: /original-bsd/lib/libc/string/strcpy.3 (revision c3e32dec)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" %sccs.include.redist.man%
9.\"
10.\"     @(#)strcpy.3	8.1 (Berkeley) 06/04/93
11.\"
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
25The
26.Fn strcpy
27and
28.Fn strncpy
29functions
30copy the string
31.Fa src
32to
33.Fa dst
34(including the terminating
35.Ql \e0
36character).
37.Pp
38The
39.Fn strncpy
40copies not more than
41.Fa len
42characters into
43.Fa dst ,
44appending
45.Ql \e0
46characters if
47.Fa src
48is less than
49.Fa len
50characters long, and
51.Em not
52terminating
53.Fa dst
54if
55.Fa src
56is more than
57.Fa len
58characters long.
59.Sh RETURN VALUES
60The
61.Fn strcpy
62and
63.Fn strncpy
64functions
65return
66.Fa dst .
67.Sh EXAMPLES
68The following sets
69.Dq Li chararray
70to
71.Dq Li abc\e0\e0\e0 :
72.Bd -literal -offset indent
73(void)strncpy(chararray, "abc", 6).
74.Ed
75.Pp
76The following sets
77.Dq Li chararray
78to
79.Dq Li abcdef :
80.Bd -literal -offset indent
81(void)strncpy(chararray, "abcdefgh", 6);
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
89The
90.Fn strcpy
91and
92.Fn strncpy
93functions
94conform to
95.St -ansiC .
96