Зачем использовать asprintf () вместо sprintf ()?

Мне трудно понять, зачем вам нужен asprintf. Здесь в руководстве это говорит

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, 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.

Вот пример, который я пытаюсь понять:

asprintf(&buffer, "/bin/echo %s is cool", getenv("USER"));

Какая разница, если буфер выделяет строку, достаточно большую, по сравнению со словами char * = (string)

Ответы на вопрос(2)

Ваш ответ на вопрос