diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2008-01-27 11:37:44 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2008-01-27 11:37:44 +0100 |
commit | 7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch) | |
tree | b1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/C/CONTRIB/SNIP/xstrcat.c |
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/C/CONTRIB/SNIP/xstrcat.c')
-rwxr-xr-x | reference/C/CONTRIB/SNIP/xstrcat.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/reference/C/CONTRIB/SNIP/xstrcat.c b/reference/C/CONTRIB/SNIP/xstrcat.c new file mode 100755 index 0000000..a1bce5b --- /dev/null +++ b/reference/C/CONTRIB/SNIP/xstrcat.c @@ -0,0 +1,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;
+}
|