| 1 |
'\" t |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH aprintf 3 2026-03-16 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
aprintf, vaprintf \- allocate and print formatted string |
| 9 |
.SH LIBRARY |
| 10 |
gnulib \- The GNU Portability Library |
| 11 |
.SH SYNOPSIS |
| 12 |
.nf |
| 13 |
.B #include <stdio.h> |
| 14 |
.P |
| 15 |
.BI char\~*aprintf(const\~char\~*restrict\~ fmt ", ...);" |
| 16 |
.BI char\~*vaprintf(const\~char\~*restrict\~ fmt ", va_list\~" ap ); |
| 17 |
.fi |
| 18 |
.SH DESCRIPTION |
| 19 |
The functions |
| 20 |
.BR aprintf () |
| 21 |
and |
| 22 |
.BR vaprintf () |
| 23 |
are analogs of |
| 24 |
.BR sprintf (3) |
| 25 |
and |
| 26 |
.BR vsprintf (3), |
| 27 |
except that their output is written |
| 28 |
in a space allocated as if by a call to |
| 29 |
.BR malloc (3). |
| 30 |
.P |
| 31 |
This pointer should be passed to |
| 32 |
.BR free (3) |
| 33 |
to release the allocated storage when it is no longer needed. |
| 34 |
.SH RETURN VALUE |
| 35 |
On success, |
| 36 |
these functions return |
| 37 |
a pointer to the first character of the formatted string. |
| 38 |
On error, |
| 39 |
\-1 is returned, |
| 40 |
and |
| 41 |
.I errno |
| 42 |
is set to indicate the error. |
| 43 |
.SH ERRORS |
| 44 |
See |
| 45 |
.BR sprintf (3) |
| 46 |
and |
| 47 |
.BR malloc (3). |
| 48 |
.SH ATTRIBUTES |
| 49 |
For an explanation of the terms used in this section, see |
| 50 |
.BR attributes (7). |
| 51 |
.TS |
| 52 |
allbox; |
| 53 |
lbx lb lb |
| 54 |
l l l. |
| 55 |
Interface Attribute Value |
| 56 |
T{ |
| 57 |
.na |
| 58 |
.nh |
| 59 |
.BR aprintf (), |
| 60 |
.BR vaprintf () |
| 61 |
T} Thread safety MT-Safe locale |
| 62 |
.TE |
| 63 |
.SH STANDARDS |
| 64 |
None. |
| 65 |
.SH HISTORY |
| 66 |
gnulib 202607. |
| 67 |
.SH SEE ALSO |
| 68 |
.BR free (3), |
| 69 |
.BR malloc (3), |
| 70 |
.BR sprintf (3), |
| 71 |
.BR strdup (3), |
| 72 |
.BR asprintf (3) |