1ASPRINTF(3)                Linux Programmer's Manual               ASPRINTF(3)
2
3
4

NAME

6       asprintf, vasprintf - print to allocated string
7

SYNOPSIS

9       #define _GNU_SOURCE
10       #include <stdio.h>
11
12       int asprintf(char **strp, const char *fmt, ...);
13
14       int vasprintf(char **strp, const char *fmt, va_list ap);
15

DESCRIPTION

17       The  functions asprintf() and vasprintf() are analogs of sprintf(3) and
18       vsprintf(3), except that they allocate a string large  enough  to  hold
19       the output including the terminating null byte, and return a pointer to
20       it via the first argument.  This pointer should be passed to free(3) to
21       release the allocated storage when it is no longer needed.
22

RETURN VALUE

24       When  successful,  these  functions return the number of bytes printed,
25       just like sprintf(3).  If memory allocation wasn't  possible,  or  some
26       other error occurs, these functions will return -1, and the contents of
27       strp is undefined.
28

CONFORMING TO

30       These functions are GNU extensions, not in C or POSIX.  They  are  also
31       available  under *BSD.  The FreeBSD implementation sets strp to NULL on
32       error.
33

SEE ALSO

35       free(3), malloc(3), printf(3), feature_test_macros(7)
36

COLOPHON

38       This page is part of release 3.25 of the Linux  man-pages  project.   A
39       description  of  the project, and information about reporting bugs, can
40       be found at http://www.kernel.org/doc/man-pages/.
41
42
43
44GNU                               2001-12-18                       ASPRINTF(3)
Impressum