version 1 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
STRCPY |
|
|
2 |
!!!STRCPY |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
BUGS |
|
|
8 |
CONFORMING TO |
|
|
9 |
SEE ALSO |
|
|
10 |
---- |
|
|
11 |
!!NAME |
|
|
12 |
|
|
|
13 |
|
|
|
14 |
strcpy, strncpy - copy a string |
|
|
15 |
!!SYNOPSIS |
|
|
16 |
|
|
|
17 |
|
|
|
18 |
__#include |
|
|
19 |
__''dest''__, const char *__''src''__); |
|
|
20 |
char *strncpy(char *__''dest''__, const char *__''src''__, size_t__ ''n''__); |
|
|
21 |
__ |
|
|
22 |
!!DESCRIPTION |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
The __strcpy()__ function copies the string pointed to by |
|
|
26 |
''src'' (including the terminating `0' character) to the |
|
|
27 |
array pointed to by ''dest''. The strings may not |
|
|
28 |
overlap, and the destination string ''dest'' must be |
|
|
29 |
large enough to receive the copy. |
|
|
30 |
|
|
|
31 |
|
|
|
32 |
The __strncpy()__ function is similar, except that not |
|
|
33 |
more than ''n'' bytes of ''src'' are copied. Thus, if |
|
|
34 |
there is no null byte among the first ''n'' bytes of |
|
|
35 |
''src'', the result wil not be |
|
|
36 |
null-terminated. |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
In the case where the length of ''src'' is less than that |
|
|
40 |
of ''n'', the remainder of ''dest'' will be padded |
|
|
41 |
with nulls. |
|
|
42 |
!!RETURN VALUE |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
The __strcpy()__ and __strncpy()__ functions return a |
|
|
46 |
pointer to the destination string ''dest''. |
|
|
47 |
!!BUGS |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
If the destination string of a __strcpy()__ is not large |
|
|
51 |
enough (that is, if the programmer was stupid/lazy, and |
|
|
52 |
failed to check the size before copying) then anything might |
|
|
53 |
happen. Overflowing fixed length strings is a favourite |
|
|
54 |
cracker technique. |
|
|
55 |
!!CONFORMING TO |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
SVID 3, POSIX, BSD 4.3, ISO 9899 |
|
|
59 |
!!SEE ALSO |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
bcopy(3), memccpy(3), memcpy(3), |
|
|
63 |
memmove(3) |
|
|
64 |
---- |