Introduction
Introduction Statistics Contact Development Disclaimer Help
test3.c - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
test3.c (861B)
---
1 #include <u.h>
2 #include <libc.h>
3 #include <stdio.h>
4
5 void
6 test(char *fmt, ...)
7 {
8 va_list arg;
9 char fmtbuf[100], stdbuf[100];
10
11 va_start(arg, fmt);
12 vsnprint(fmtbuf, sizeof fmtbuf, fmt, arg);
13 va_end(arg);
14
15 va_start(arg, fmt);
16 vsnprint(stdbuf, sizeof stdbuf, fmt, arg);
17 va_end(arg);
18
19 if(strcmp(fmtbuf, stdbuf) != 0)
20 print("fmt %s: fmt=\"%s\" std=\"%s\"\n", fmt, fmtbuf, st…
21
22 print("fmt %s: %s\n", fmt, fmtbuf);
23 }
24
25
26 int
27 main(int argc, char *argv[])
28 {
29 test("%f", 3.14159);
30 test("%f", 3.14159e10);
31 test("%f", 3.14159e-10);
32
33 test("%e", 3.14159);
34 test("%e", 3.14159e10);
35 test("%e", 3.14159e-10);
36
37 test("%g", 3.14159);
38 test("%g", 3.14159e10);
39 test("%g", 3.14159e-10);
40
41 test("%g", 2e25);
42 test("%.18g", 2e25);
43
44 test("%2.18g", 1.0);
45 test("%2.18f", 1.0);
46 test("%f", 3.1415927/4);
47
48 test("%20.10d", 12345);
49 test("%0.10d", 12345);
50
51 return 0;
52 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.