#include #include static void vsnprintf_test(char **str, size_t *alloc_len, size_t *offset, const char *fmt, ...) { va_list args; if (NULL == *str) { char buf[1]; va_start(args, fmt); printf("Calling vsnprintf()\n"); int res = vsnprintf(buf, sizeof(buf), fmt, args); printf("After vsnprintf(): res = %d\n", res); va_end(args); *offset = 0; } } int main(void) { char *msg = NULL; size_t msg_alloc = 0, msg_offset = 0; vsnprintf_test(&msg, &msg_alloc, &msg_offset, "%s", "ABC"); }