add ANSI contribution notice
[unix-history] / usr / src / lib / libc / string / strcpy.3
CommitLineData
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
25The
26.Fn strcpy
ee7c1421 27and
ae59e04c
CL
28.Fn strncpy
29functions
30copy the string
31.Fa src
657bdb9b 32to
ae59e04c
CL
33.Fa dst
34(including the terminating
35.Ql \e0
36character).
37.Pp
38The
39.Fn strncpy
40copies not more than
41.Fa len
ee7c1421 42characters into
ae59e04c
CL
43.Fa dst ,
44appending
45.Ql \e0
46characters if
47.Fa src
ee7c1421 48is less than
ae59e04c 49.Fa len
ee7c1421 50characters long, and
ae59e04c 51.Em not
ee7c1421 52terminating
ae59e04c 53.Fa dst
ee7c1421 54if
ae59e04c 55.Fa src
ee7c1421 56is more than
ae59e04c 57.Fa len
ee7c1421 58characters long.
ae59e04c
CL
59.Sh RETURN VALUES
60The
61.Fn strcpy
ee7c1421 62and
ae59e04c
CL
63.Fn strncpy
64functions
ee7c1421 65return
ae59e04c
CL
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
ee7c1421 73(void)strncpy(chararray, "abc", 6).
ae59e04c
CL
74.Ed
75.Pp
76The following sets
77.Dq Li chararray
78to
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
89The
90.Fn strcpy
ee7c1421 91and
ae59e04c
CL
92.Fn strncpy
93functions
94conform to
95.St -ansiC .