test_asprintf.c (331B)
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 #ifndef __clang__ 15 asprintf(&buf, "total: %", 1); 16 assert(buf == NULL); 17 #endif 18 19 return 0; 20 }