1STRCPY(3)                  Linux Programmer's Manual                 STRCPY(3)
2
3
4

NAME

6       strcpy, strncpy - copy a string
7

SYNOPSIS

9       #include <string.h>
10
11       char *strcpy(char *dest, const char *src);
12
13       char *strncpy(char *dest, const char *src, size_t n);
14

DESCRIPTION

16       The  strcpy()  function  copies the string pointed to by src (including
17       the terminating `\0' character) to the array pointed to by  dest.   The
18       strings  may not overlap, and the destination string dest must be large
19       enough to receive the copy.
20
21       The strncpy() function is similar, except that not more than n bytes of
22       src  are copied. Thus, if there is no null byte among the first n bytes
23       of src, the result will not be null-terminated.
24
25       In the case where the length of src is less than that of n, the remain‐
26       der of dest will be padded with null bytes.
27

RETURN VALUE

29       The  strcpy()  and strncpy() functions return a pointer to the destina‐
30       tion string dest.
31

BUGS

33       If the destination string of a strcpy() is not large enough  (that  is,
34       if  the programmer was stupid/lazy, and failed to check the size before
35       copying) then anything might happen.  Overflowing fixed length  strings
36       is a favourite cracker technique.
37

CONFORMING TO

39       SVr4, 4.3BSD, C89, C99.
40

SEE ALSO

42       bcopy(3), memccpy(3), memcpy(3), memmove(3), wcscpy(3), wcsncpy(3)
43
44
45
46GNU                               1993-04-11                         STRCPY(3)
Impressum