Scroll to navigation

asprintf(3) Library Functions Manual asprintf(3)

НАИМЕНОВАНИЕ

asprintf, vasprintf - выводит данные в строку, выделенную в памяти

БИБЛИОТЕКА

Стандартная библиотека языка C (libc-lc)

ОБЗОР

#define _GNU_SOURCE         /* см. 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.

ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ

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.

ОШИБКИ

See sprintf(3) and malloc(3).

АТРИБУТЫ

Описание терминов данного раздела смотрите в attributes(7).

Интерфейс Атрибут Значение
asprintf(), vasprintf() Безвредность в нитях MT-Safe locale

ВЕРСИИ

The FreeBSD implementation sets strp to NULL on error.

СТАНДАРТЫ

GNU, BSD.

СМОТРИТЕ ТАКЖЕ

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

ПЕРЕВОД

Русский перевод этой страницы руководства разработал(и) Dmitry Bolkhovskikh <d20052005@yandex.ru>, Yuri Kozlov <yuray@komyakino.ru> и Kirill Rekhov <krekhov.dev@gmail.com>

Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, https://www.gnu.org/licenses/gpl-3.0.html версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ.

Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу списка рассылки русских переводчиков.

21 мая 2025 г. Справочные страницы Linux (невыпущенные)