Browse Source Download (without any required ccan dependencies)

Module:

asprintf

Summary:

asprintf wrapper (and if necessary, implementation).

Author:

Rusty Russell <rusty@rustcorp.com.au>

Dependencies:

Description:

This provides a convenient wrapper for asprintf, and also implements asprintf if necessary.

Example:

#include <ccan/asprintf/asprintf.h>
#include <unistd.h>
#include <err.h>

int main(int argc, char *argv[])
{
        char *p = afmt("This program has %i arguments", argc);
        int ret;

        while ((ret = write(STDOUT_FILENO, p, strlen(p))) > 0) {
                p += ret;
                if (!*p)
                        exit(0);
        }
        err(1, "Writing to stdout");
}

License:

MIT