char *concat(buf, buflen, str1, str2, ..., NULL);
char *buf;
int buflen;
char *str1, *str2, ...; #include <varargs.h> char *vconcat(buf, buflen, ap)
char *buf;
int buflen;
va_list ap;
Concat will return NULL if buf is NULL, if buflen is <= 0, or if the concatenation of the string pointers did not fit into buf. In all other cases, concat will terminate the concatenation with a null (0) byte and return a pointer to the null byte.
Vconcat is a varargs version of concat which may be used by routines to concatenate their string pointer argument list into a buffer.
end = concat(buf, buflen, dir, "/", file, NULL);
could be used to generate a file path from a directory name and a file name, returning a pointer to the end of the path.
concat(end, buf+buflen-end, ".", ext, NULL);
could then be used to add an extension to the file path.