#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
char *valist_to_buf(const char *format, ...)
{
char *p;
va_list ap;
if ((p = malloc(4096)) == NULL)
{
return (NULL);
}
va_start(ap, format);
(void)vsnprintf(p, 128, format, ap);
va_end(ap);
return (p);
}
int main()
{
char *buf = valist_to_buf("=%=%%=%d=%x=%ld=%f=%c=%s\n", 1, 10, 999999999999999, 0.9f, 'c', "abc");
printf("%s", buf);
puts(buf);
free(buf);
return 0;
}