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