Next: , Previous: Formatted I/O, Up: Formatted I/O


15.1 Functions for formatted output

— Function: ssize_t file_printf (FILE *stream, const char *fmt, ...)
— Function: ssize_t file_vprintf (FILE *stream, const char *fmt, va_list va)

These functions format output onto stream according to fmt and any subsequent arguments, returning the number of characters formatted. For ‘file_vprintf’, subsequent arguments are obtained from va.

— Function: ssize_t astr_printf (Autostr *string, const char *fmt, ...)
— Function: ssize_t astr_vprintf (Autostr *string, const char *fmt, va_list va)

These functions format output onto string according to fmt and any subsequent arguments, returning the number of characters formatted. Any previous contents of string are deleted. For ‘astr_vprintf’, subsequent arguments are obtained from va.

— Function: ssize_t astr_printa (Autostr *string, const char *fmt, ...)
— Function: ssize_t astr_vprinta (Autostr *string, const char *fmt, va_list va)

These functions format output onto the end of string according to fmt and any subsequent arguments, returning the number of characters formatted. For ‘astr_vprinta’, subsequent arguments are obtained from va.

— Function: ssize_t as_printf (char **as, const char *fmt, ...)
— Function: ssize_t as_vprintf (char **as, const char *fmt, va_list va)

These functions format output onto *as according to fmt and any subsequent arguments, returning the number of characters formatted. *as must either be ‘NULL’ or a pointer to a block of memory allocated with ‘malloc’; it will be reallocated to be big enough to hold the formatted output. For ‘as_vprintf’, subsequent arguments are obtained from va.

— Function: ssize_t asn_printf (char **as, ssize_t *n, const char *fmt, ...)
— Function: ssize_t asn_vprintf (char **as, ssize_t *n, const char *fmt, va_list va)

These functions format output onto *as according to fmt and any subsequent arguments, returning the number of characters formatted. Either *as must be ‘NULL’ and *n zero, or *as must be a pointer to a block of memory *n bytes long that was allocated with ‘malloc’. On exit, *as points to a block of memory *n bytes long that was allocated with ‘malloc’. For ‘as_vprinta’, subsequent arguments are obtained from va.

— Function: ssize_t asn_printa (char **as, ssize_t *n, const char *fmt, ...)
— Function: ssize_t asn_vprinta (char **as, ssize_t *n, const char *fmt, va_list va)

These functions format output onto the end of *as according to fmt and any subsequent arguments, returning the number of characters formatted. Either *as must be ‘NULL’ and *n zero, or *as must be a pointer to a block of memory *n bytes long that was allocated with ‘malloc’. On exit, *as points to a block of memory *n bytes long that was allocated with ‘malloc’. For ‘as_vprinta’, subsequent arguments are obtained from va.