1STPCPY(3) Linux Programmer's Manual STPCPY(3)
2
3
4
6 stpcpy - copy a string returning a pointer to its end
7
9 #define _GNU_SOURCE
10 #include <string.h>
11
12 char *stpcpy(char *dest, const char *src);
13
15 The stpcpy() function copies the string pointed to by src (including
16 the terminating `\0' character) to the array pointed to by dest. The
17 strings may not overlap, and the destination string dest must be large
18 enough to receive the copy.
19
21 stpcpy() returns a pointer to the end of the string dest (that is, the
22 address of the terminating null byte) rather than the beginning.
23
25 For example, this program uses stpcpy() to concatenate foo and bar to
26 produce foobar, which it then prints.
27
28 #include <string.h>
29
30 int
31 main (void)
32 {
33 char *to = buffer;
34 to = stpcpy (to, "foo");
35 to = stpcpy (to, "bar");
36 printf ("%s\n", buffer);
37 }
38
40 This function is not part of the C or POSIX.1 standards, and is not
41 customary on Unix systems, but is not a GNU invention either. Perhaps
42 it comes from MS-DOS.
43
45 bcopy(3), memccpy(3), memcpy(3), memmove(3), strcpy(3), wcpcpy(3), fea‐
46 ture_test_macros(7)
47
48
49
50GNU 1995-09-03 STPCPY(3)