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