home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_03
/
8n03099a
< prev
next >
Wrap
Text File
|
1990-03-20
|
574b
|
38 lines
*** Listing 4 ***
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
/*
* Concatenate copies of a variable number strings into
* s1. The list of strings must be terminated by NULL.
* concat returns s1.
*/
char *concat(char *s1, ...)
{
char *s = s1;
const char *t;
va_list ap;
va_start(ap, s1);
while ((t = va_arg(ap, const char *)) != NULL)
{
strcpy(s, t);
s += strlen(s);
}
va_end(ap);
return s1;
}
int main(void)
{
char s[100];
puts(concat(s, "This ", "is ", "great!", NULL));
return 0;
}