-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
229 lines (156 loc) · 8.8 KB
/
main.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abkssiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/11 15:21:53 by abkssiba #+# #+# */
/* Updated: 2019/12/14 16:46:08 by abkssiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "../ft_printf.h"
#include <stdio.h>
int main()
{
unsigned long p;
char *str = "hello";
/* ---------------------- integer ---------------------- */
// printf("%d\n", ft_printf("%09.*d\n", -1, 22));
// printf("%d\n", printf("%09.*d\n", -1, 22));
/* unsigned */
// printf("%u\n", ft_printf("%015.3d\n", UINT32_MAX + 2));
// printf("%u\n", printf("%015.3d\n", UINT32_MAX + 2));
// printf("%u\n", ft_printf("%*d\n",4, -3));
// printf("%u\n", printf("%*d\n",4, -3));
// printf("%d\n", ft_printf("%*10.*d\n", 4,3, 80));
// printf("%d\n", printf("%*10.*d\n", 4,3, 80));
// printf("%u\n", ft_printf("%015.6u\n", UINT32_MAX + 95));
// printf("%u\n", printf("%015.6u\n", UINT32_MAX + 95));
// printf("%u\n", ft_printf("%u\n", UINT32_MAX));
// printf("%u\n", printf("%u\n", UINT32_MAX));
// printf("%d\n", ft_printf("%5d\n", 4));
// printf("%d\n", printf("%5d\n", 4));
// printf("%d\n", ft_printf("%05d\n", -4));
// printf("%d\n", printf("%05d\n", -4));
// printf("%d\n", ft_printf("%5.d\n", -4));
// printf("%d\n", printf("%5.d\n", -4));
// printf("%d\n", ft_printf("%*d\n",4, -3));
// printf("%d\n", printf("%*d\n",4, -3));
// printf("%d\n", ft_printf("%-*.*d\n", 4,3,1));
// printf("%d\n", printf("%-*.*d\n",4,3, 1));
//
// printf("\n%d\n", ft_printf("%04d", 5));
// printf("\n%d\n", printf("%04d", 5));
// printf("\n%d\n", ft_printf("%05.3d", 12));
// printf("\n%d\n", printf("%05.3d", 12));
// printf("\n%d\n", ft_printf("%5.d", 0));
// printf("\n%d\n", printf("%5.d", 0));
// printf("%d\n", ft_printf("%2.04d\n", 1));
// printf("%d\n", printf("%2.04d\n", 1));
// printf("\n%d\n", ft_printf("%05.0d", -12));
// printf("\n%d\n", printf("%05.0d", -12));
// printf("\n%d\n", ft_printf("%3.0d", 12));
// printf("\n%d\n", printf("%3.0d", 12));
// printf("\n%d\n", ft_printf("%05d", 12));
// printf("\n%d\n", printf("%05d", 12));
// printf("%d\n", ft_printf("%*.*d\n", 10, 3, 32));
// printf("%d\n", printf("%*.*d\n", 10, 3, 32));
// printf("%d\n", ft_printf("%0*.*d\n", 10,5, -32));
// printf("%d\n", printf("%0*.*d\n", 10,5, -32));
// printf("%d\n", ft_printf("%*.05d\n", 10, 32));
// printf("%d\n", printf("%*.05d\n", 10, 32));
printf("%d\n", ft_printf("%20d\n", -2147483647));
printf("%d\n", printf("%20d\n", -2147483647));
// printf("%d\n", ft_printf("%4d\n", 2));
// printf("%d\n", printf("%4d\n", 2));
// printf("%d\n", ft_printf("%0-4d\n", 2));
// printf("%d\n", printf("%0-4d\n", 2));
// printf("%d\n", ft_printf("%-.3d\n",-2));
// printf("%d\n", printf("%-.3d\n",-2));
// printf("%d\n", ft_printf("%05.3d\n", 12));
// printf("%d\n", printf("%05.3d\n", 12));
// printf("%d\n", ft_printf("%4.2d\n", 0));
// printf("%d\n", printf("%4.2d\n", 0));
// printf("%d\n", ft_printf("%04i\n", 22));
// printf("%d\n", printf("%04i\n", 22));
// printf("%d\n", ft_printf("%4.2d\n", 1));
// printf("%d\n", printf("%4.2d\n", 1));
// printf("%d\n", ft_printf("%*.*d\n", 4, 4, 1));
// printf("%d\n", printf("%*.*d\n", 4, 4, 1));
/* ---------------------- hexa ---------------------- */
// printf("%d\n", ft_printf("%-6.x\n", 1533));
// printf("%d\n", printf("%-6.x\n", 1533));
// printf("%d\n", ft_printf("%x\n", UINT32_MAX + INT32_MIN));
// printf("%d\n", printf("%x\n", UINT32_MAX + INT32_MIN));
// printf("%d\n", ft_printf("%x\n", UINT32_MAX - 1));
// printf("%d\n", printf("%x\n", UINT32_MAX - 1));
// printf("%d\n", ft_printf("%-5x\n", 1512));
// printf("%d\n", printf("%-5x\n", 1512));
// printf("%d\n", ft_printf("%5.*x\n",4, 1512));
// printf("%d\n", printf("%5.*x\n",4, 1512));
// printf("%d\n", ft_printf("%015x",0x99));
// printf("%d\n", printf("%015x",0x99));
// printf("%d\n", ft_printf("%*X",300, 1));
// printf("%d\n", printf("%*X",300, 1));
// printf("%d\n", ft_printf("%015x",99));
// printf("%d\n", printf("%015x",99));
// printf("%d\n", ft_printf("%x\n",0));
// printf("%d\n", printf("%x\n",0));
// printf("%d\n", ft_printf("%p\n",(void *)0x100));
// printf("%d\n", printf("%p\n",(void *)0x100));
// printf("%d\n", ft_printf("%---15X %00015x\n",33, 0x99));
// printf("%d\n", printf("%---15X %00015x\n",33, 0x99));
/* ---------------------- huh?? ---------------------- */
// printf("\n%d\n", ft_printf("%5*w", -12));
// printf("\n%d\n", printf("%5*w", -12));
// printf("\n%d\n", ft_printf("%3.*", 12));
// printf("\n%d\n", printf("%3.*", 12));
/* ---------------------- string ---------------------- */
// printf("%d\n", ft_printf("%*.*s\n", 6, 2, "hello"));
// printf("%d\n", printf("%*.*s\n", 6, 2, "hello"));
// printf("%d\n", ft_printf("%10*.1*s\n", 7,3,"hello"));
// printf("%d\n", printf("%10*.1*s\n", 7,3,"hello"));
// printf("%d\n", ft_printf("%-*.*s,%.s,%s|%-6s|,>%s<,%*.*s\n", 6, 2, "hello", NULL, "wu", "world", NULL, 5, 2, "TYUI"));
// printf("%d\n", printf("%-*.*s,%.s,%s|%-6s|,>%s<,%*.*s\n", 6, 2, "hello", NULL, "wu", "world", NULL, 5, 2, "TYUI"));
// printf("%d\n", ft_printf("%*.*s %s,%-3.*s '%-2c-%.c'||%s<%%>\n", 6, 2, "hello" , NULL, 1,"ld", 'r', 0,"wow"));
// printf("%d\n", printf("%*.*s %s,%-3.*s '%-2c-%.c'||%s<%%>\n", 6, 2, "hello" , NULL, 1,"ld", 'r', 0,"wow"));
// ft_printf("%*2s\n", 2, "h");
// printf("%*2s\n", 2, "h");
// ft_printf("%*s\n", 0, "h");
// printf("%*s\n", 0, "h");
/* ---------------------- NULL ---------------------- */
// printf("%d\n", ft_printf("%1.1s\n", NULL));
// printf("%d\n", printf("%1.1s\n", NULL));
// printf("\n%d\n", ft_printf("%*.*s", -15, 0, NULL));
// printf("\n%d\n", printf("%*.*s", -15, 0, NULL));
/* ---------------------- %% && c ---------------------- */
// printf("%d\n", ft_printf("%-5%%02%\n"));
// printf("%d\n", printf("%-5%%02%\n"));
// printf("%d\n", ft_printf("%.5c\n", 50));
// printf("%d\n", printf("%.5c\n",50));
// printf("%d\n", ft_printf("%c\n", 0));
// printf("%d\n", printf("%c\n", 0));
/* ---------------------- address ---------------------- */
// printf("%d\n", ft_printf("%*p\n", -16, &p));
// printf("%d\n", printf("%*p\n", -16, &p));
// printf("%d\n", ft_printf("%p\n", &p));
// printf("%d\n", printf("%p\n", &p));
// printf("\n%d\n", ft_printf("%p", (void*)-12));
// printf("\n%d\n", printf("%p", (void*)-12));
// printf("%d\n", ft_printf("%-8p\n", (void*)0xef));
// printf("%d\n", printf("%-8p\n", (void*)0xef));
// printf("%d\n", ft_printf("%-8p\n", (void*)100));
// printf("%d\n", printf("%-8p\n", (void*)100));
/* ---------------------- ultimate test ---------------------- */
// printf("%d\n", ft_printf("%*.*s %s,%-3.*s '%-2c-%.c'|%.%%p|%s<%0*%>\n", 6, 2, str , NULL, 1,"ld", 'r', 0, &p,"wow", 2));
// printf("%d\n", printf("%*.*s %s,%-3.*s '%-2c-%.c'|%.%%p|%s<%0*%>\n", 6, 2, str, NULL, 1,"ld", 'r', 0, &p, "wow", 2));
// printf("%d\n", ft_printf("ultimate2 %*d %*s %*x %*X %*i %*u\n", 1, 5000, 1, "hey", 10, 50000, 1, 300, 22, -55, 1, -60));
// printf("%d\n", printf("ultimate2 %*d %*s %*x %*X %*i %*u\n", 1, 5000, 1, "hey", 10, 50000, 1, 300, 22, -55, 1, -60));
// printf("%d\n", ft_printf("ultimate3 %*.*d %*.*s\n", 1, 50, 5000, 1, 0, "hey"));
// printf("%d\n", printf("ultimate3 %*.*d %*.*s\n", 1, 50, 5000, 1, 0, "hey"));
// printf("%d\n", ft_printf("TEST TEST 0000%%%*.*s%%%-15.8dTEST%-15.8u0000000\t%%%15%%.3% %---15d %00015x\n", 7,5, "ABC",15,0,20,0x99));
// printf("%d\n", printf("TEST TEST 0000%%%*.*s%%%-15.8dTEST%-15.8u0000000\t%%%15%%.3% %---15d %00015x\n", 7,5, "ABC",15,0,20,0x99));
// printf("%d\n",ft_printf("hello fghjk's %%%s%%%s call his %02%%-2%%%%s\n" ,"friend","fghjk","dad"));
// printf("%d\n",printf("hello fghjk's %%%s%%%s call his %02%%-2%%%%s\n" ,"friend","fghjk","dad"));
}