'\" t .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .TH aprintf 3 2026-03-16 "Linux man-pages 6.18" .SH NAME aprintf, vaprintf \- allocate and print formatted string .SH LIBRARY gnulib \- The GNU Portability Library .SH SYNOPSIS .nf .B #include .P .BI char\~*aprintf(const\~char\~*restrict\~ fmt ", ...);" .BI char\~*vaprintf(const\~char\~*restrict\~ fmt ", va_list\~" ap ); .fi .SH DESCRIPTION The functions .BR aprintf () and .BR vaprintf () are analogs of .BR sprintf (3) and .BR vsprintf (3), except that their output is written in a space allocated as if by a call to .BR malloc (3). .P This pointer should be passed to .BR free (3) to release the allocated storage when it is no longer needed. .SH RETURN VALUE On success, these functions return a pointer to the first character of the formatted string. On error, \-1 is returned, and .I errno is set to indicate the error. .SH ERRORS See .BR sprintf (3) and .BR malloc (3). .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). .TS allbox; lbx lb lb l l l. Interface Attribute Value T{ .na .nh .BR aprintf (), .BR vaprintf () T} Thread safety MT-Safe locale .TE .SH STANDARDS None. .SH HISTORY gnulib 202607. .SH SEE ALSO .BR free (3), .BR malloc (3), .BR sprintf (3), .BR strdup (3), .BR asprintf (3)