summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/xstrcat.c
blob: a1bce5bda3ca51a5ebbbe8e01d446ea07da571e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
**  XSTRCAT.C - String concatenation function
**
**  Notes: 1st argument must be a buffer large enough to contain the
**         concatenated strings.
**
**         2nd thru nth arguments are the string to concatenate.
**
**	     (n+1)th argument must be NULL to terminate the list.
*/

#include <stdarg.h>

char *xstrcat(char *des, char *src, ...)
{
        char *destination = des;
        va_list v;

        va_start(v, src);

        while (src != 0)
        {
                while (*src != 0)
                        *des++ = *src++;
                src = va_arg(v, char *);
        }
        *des = 0;

        va_end(v);

        return destination;
}