1
void foo(const char *format, ...)
6
long long l = 1234567890;
10
len = vsnprintf(buf, 0, format, ap);
12
if (len != 5) exit(1);
15
len = vsnprintf(0, 0, format, ap);
17
if (len != 5) exit(2);
19
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
21
if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
22
if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
23
if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
24
if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
29
main() { foo("hello"); }