-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprintf_specifiers.c
More file actions
30 lines (25 loc) · 1.22 KB
/
printf_specifiers.c
File metadata and controls
30 lines (25 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#define _STRINGIZE(x) #x
#define STRINGIZE(x) _STRINGIZE(x)
#define PRINTF(fmt, ...) printf("- \"%s\"\n", fmt " " STRINGIZE(__VA_ARGS__)); printf(fmt "\n", __VA_ARGS__)
int main(int argc, char const *argv[])
{
(void)argc;
(void)argv;
PRINTF("%d", 1);
puts(" RIGHT JUSTIFY");
puts("-----------------------------------------------------------------------------------------------------------");
PRINTF("%3d hello", 1);
PRINTF("%3d hello", 123);
PRINTF("%3d hello", 12345);
PRINTF("%03d hello", 1);
puts("-----------------------------------------------------------------------------------------------------------");
puts("");
puts(" LEFT JUSTIFY");
puts("-----------------------------------------------------------------------------------------------------------");
PRINTF("%-3d hello", 1);
PRINTF("%-3d hello", 123);
PRINTF("%-3d hello", 12345);
puts("-----------------------------------------------------------------------------------------------------------");
return 0;
}