test.c - 9base - revived minimalist port of Plan 9 userland to Unix | |
git clone git://git.suckless.org/9base | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
test.c (1844B) | |
--- | |
1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ | |
2 /* Copyright (c) 2004 Google Inc.; see LICENSE */ | |
3 | |
4 #include <stdio.h> | |
5 #include <stdarg.h> | |
6 #include <utf.h> | |
7 #include "plan9.h" | |
8 #include "fmt.h" | |
9 #include "fmtdef.h" | |
10 | |
11 int | |
12 main(int argc, char *argv[]) | |
13 { | |
14 quotefmtinstall(); | |
15 print("hello world\n"); | |
16 print("x: %x\n", 0x87654321); | |
17 print("u: %u\n", 0x87654321); | |
18 print("d: %d\n", 0x87654321); | |
19 print("s: %s\n", "hi there"); | |
20 print("q: %q\n", "hi i'm here"); | |
21 print("c: %c\n", '!'); | |
22 print("g: %g %g %g\n", 3.14159, 3.14159e10, 3.14159e-10); | |
23 print("e: %e %e %e\n", 3.14159, 3.14159e10, 3.14159e-10); | |
24 print("f: %f %f %f\n", 3.14159, 3.14159e10, 3.14159e-10); | |
25 print("smiley: %C\n", (Rune)0x263a); | |
26 print("%g %.18g\n", 2e25, 2e25); | |
27 print("%2.18g\n", 1.0); | |
28 print("%2.18f\n", 1.0); | |
29 print("%f\n", 3.1415927/4); | |
30 print("%d\n", 23); | |
31 print("%i\n", 23); | |
32 print("%0.10d\n", 12345); | |
33 | |
34 /* test %4$d formats */ | |
35 print("%3$d %4$06d %2$d %1$d\n", 444, 333, 111, 222); | |
36 print("%3$d %4$06d %2$d %1$d\n", 444, 333, 111, 222); | |
37 print("%3$d %4$*5$06d %2$d %1$d\n", 444, 333, 111, 222, 20); | |
38 print("%3$hd %4$*5$06d %2$d %1$d\n", 444, 333, (short)111, 222, … | |
39 print("%3$lld %4$*5$06d %2$d %1$d\n", 444, 333, 111LL, 222, 20); | |
40 | |
41 /* test %'d formats */ | |
42 print("%'d %'d %'d\n", 1, 2222, 33333333); | |
43 print("%'019d\n", 0); | |
44 print("%08d %08d %08d\n", 1, 2222, 33333333); | |
45 print("%'08d %'08d %'08d\n", 1, 2222, 33333333); | |
46 print("%'x %'X %'b\n", 0x11111111, 0xabcd1234, 12345); | |
47 print("%'lld %'lld %'lld\n", 1LL, 222222222LL, 3333333333333LL); | |
48 print("%019lld %019lld %019lld\n", 1LL, 222222222LL, 33333333333… | |
49 print("%'019lld %'019lld %'019lld\n", 1LL, 222222222LL, 33333333… | |
50 print("%'020lld %'020lld %'020lld\n", 1LL, 222222222LL, 33333333… | |
51 print("%'llx %'llX %'llb\n", 0x111111111111LL, 0xabcd12345678LL,… | |
52 return 0; | |
53 } |