asprintf(3) Library Functions Manual asprintf(3)

asprintf, vasprintf - imprimen en una cadena reservada

Biblioteca Estándar C (libc, -lc)

#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);

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.

Cuando tienen éxito, estas funciones devuelven el número de bytes impresos, al igual que sprintf(3). Si la reserva de memoria no se pudo llevar a cabo, o ocurre algun otro error, estas funciones devuelven -1, y el contenido de strp queda indefinido.

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

The FreeBSD implementation sets strp to NULL on error.

GNU, BSD.

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

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.

31 Octubre 2023 Páginas de manual de Linux 6.06