Scroll to navigation

asprintf(3) Library Functions Manual asprintf(3)

NOMBRE

asprintf, vasprintf - imprimen en una cadena reservada

BIBLIOTECA

Biblioteca Estándar C (libc-lc)

SINOPSIS

#define _GNU_SOURCE         /* Vea feature_test_macros(7) */
#include <stdio.h>
int asprintf(char **restrict strp, const char *restrict fmt, ...);
int vasprintf(char **restrict strp, const char *restrict fmt,
              va_list ap);

DESCRIPCIÓN

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

VALOR DEVUELTO

When successful, these functions return the number of bytes printed, just like sprintf(3). On error, -1 is returned, errno is set to indicate the error, and the contents of strp are undefined.

ERRORES

See sprintf(3) and malloc(3).

ATRIBUTOS

Para obtener una explicación de los términos usados en esta sección, véase attributes(7).

Interfaz Atributo Valor
asprintf(), vasprintf() Seguridad del hilo Configuración regional de multi-hilo seguro

VERSIONES

The FreeBSD implementation sets strp to NULL on error.

ESTÁNDARES

GNU, BSD.

VÉASE TAMBIÉN

free(3), malloc(3), printf(3)

TRADUCCIÓN

La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars <mpi79470@alu.um.es>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

8 Febrero 2026 Páginas de Manual de Linux 6.17