test_asprintf.c (344B)
1 #define _GNU_SOURCE 2 #include "common.h" 3 4 #include <assert.h> 5 #include <stdio.h> 6 #include <stdlib.h> 7 8 int main(int argc, char** argv) { 9 char* buf; 10 asprintf(&buf, "total: %d+%d=%d", 1, 2, 3); 11 puts(buf); 12 free(buf); 13 14 #if 0 15 #ifndef __clang__ 16 asprintf(&buf, "total: %", 1); 17 assert(buf == NULL); 18 #endif 19 #endif 20 21 return 0; 22 }