stracat(3pub)

stracat3pub

Concatenate many strings into an allocated memory block

Usage

#include <publib.h>
char *stracat(const char *s, ...);

Overview

stracat will allocate a block of memory with malloc and concatenate all arguments strings into this block. The user is supposed to free the returned block. The end of the argument list is signalled by a null pointer.

Return value

stracat returns a pointer to the allocated block, or NULL if it could not be allocated.

Examples

To concatenate "hello, " and "world", one might say the following.

p = stracat("hello, ", "world", (char *)NULL);
if (p != NULL)
	puts(p);

Please note that it is necessary to case NULL as in the example above,
since there is no information about the type of the argument available
in the prototype, and since an unadorned NULL might not be of the 
correct type.  (See any good C reference book or the comp.lang.c FAQ for
more information.)

Releases

16 releases since Debian 1.2 (Rex); the text changed 4 times.

  1. 1.2–1.3
  2. 2.0–2.2
  3. 3.0
  4. 3.1–6.0
  5. 7–13

Author

Lars Wirzenius ([email protected])

From publib-dev 0.40-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.