Next: , Previous: str_dup, Up: Strings   [Contents]


4.2 str_join

concatenate strings with delimiters

Synopsis

#include <suplib/str.h>

char *str_join(
  const char *delim,
  size_t n,
  ...
);

Parameters

const char *delim

the inter-string delimiter, may be NULL

size_t n

the number of strings

...

the strings

Description

str_join concatenates a list of strings, separated by the given delimiter. If any of the passed pointers is NULL, it is ignored.

Returns

It returns a pointer to a newly allocated buffer containing the the concatenated string, NULL if it couldn’t allocate the requisite memory. The caller is responsible for freeing the buffer.