-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
233 lines (231 loc) · 8.73 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
230
231
232
233
#include "ft_printf.h"
#include <limits.h>
#include <stdio.h>
int main(void)
{
int i;
int z;
void *ptr;
int *intp;
char *charp;
char *strp;
unsigned int *unsignedp;
char *s;
s = NULL;
ft_putstr_fd("Test 1: Char\n---------------\n\n", 1);
z = ft_printf("Printf 1: %c\n", 'A');
i = printf("Printf 2: %c\n", 'A');
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: Char\n---------------\n\n", 1);
z = ft_printf("Printf 1: %c\n", 'A');
i = printf("Printf 2: %c\n", 'A');
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: Char\n---------------\n\n", 1);
z = ft_printf("Printf 1: %c\n", -1);
i = printf("Printf 2: %c\n", -1);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 1: Int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %i\n", 0);
i = printf("Printf 2: %i\n", 0);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: Int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %i\n", 10);
i = ft_printf("Printf 1: %i\n", -10);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
z = printf("Printf 2: %i\n", 10);
i = printf("Printf 2: %i\n", -10);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 3: Int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %i\n", 5324);
i = ft_printf("Printf 1: %i\n", -5324);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
z = printf("Printf 2: %i\n", 5324);
i = printf("Printf 2: %i\n", -5324);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: Int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %i\n", INT_MAX);
i = ft_printf("Printf 1: %i\n", INT_MIN);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
z = printf("Printf 2: %i\n", INT_MAX);
i = printf("Printf 2: %i\n", INT_MIN);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 5: Int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %i\n", NULL);
i = printf("Printf 2: %i\n", NULL);
printf("\nReturn: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 1: String\n---------------\n\n", 1);
z = ft_printf("Printf 1: %s\n\n", "Hello World!");
i = printf("Printf 2: %s\n\n", "Hello World!");
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: String\n---------------\n\n", 1);
z = ft_printf("Printf 1: %s\n\n", "asdasdasdasdasdsadasdasdasdasdasdsadsadsadsadsadsadad");
i = printf("Printf 2: %s\n\n", "asdasdasdasdasdsadasdasdasdasdasdsadsadsadsadsadsadad");
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 3: String\n---------------\n\n", 1);
z = ft_printf("Printf 1: %s\n\n", "");
i = printf("Printf 2: %s\n\n", "");
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: String\n---------------\n\n", 1);
z = ft_printf("Printf 1: %s\n\n", "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
i = printf("Printf 2: %s\n\n", "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 5: String\n---------------\n\n", 1);
z = ft_printf("Printf 1: %s\n\n", s);
i = printf("Printf 2: %s\n\n", s);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 1: Pointer\n---------------\n\n", 1);
int a = 15;
intp = &a;
z = ft_printf("Printf 1: %p\n\n", intp);
i = printf("Printf 2: %p\n\n", intp);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: Pointer\n---------------\n\n", 1);
char b = 'A';
charp = &b;
z = ft_printf("Printf 1: %p\n\n", charp);
i = printf("Printf 2: %p\n\n", charp);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 3: Pointer\n---------------\n\n", 1);
char *c = "Hello";
strp = c;
z = ft_printf("Printf 1: %p\n\n", strp);
i = printf("Printf 2: %p\n\n", strp);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: Pointer\n---------------\n\n", 1);
unsigned int d = 40968;
unsignedp = &d;
z = ft_printf("Printf 1: %p\n\n", unsignedp);
i = printf("Printf 2: %p\n\n", unsignedp);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 5: Pointer\n---------------\n\n", 1);
ptr = NULL;
z = ft_printf("Printf 1: %p\n\n", ptr);
i = printf("Printf 2: %p\n\n", ptr);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 1: Unsigned int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %u\n\n", 0);
i = printf("Printf 2: %u\n\n", 0);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: Unsigned int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %u\n\n", 236326);
i = printf("Printf 2: %u\n\n", 236326);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 3: Unsigned int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %u\n\n", UINT_MAX);
i = printf("Printf 2: %u\n\n", UINT_MAX);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: Unsigned int\n---------------\n\n", 1);
z = ft_printf("Printf 1: %u\n\n", -1);
i = printf("Printf 2: %u\n\n", -1);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 1: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", 0);
i = printf("Printf 2: %x\n\n", 0);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", 44);
i = printf("Printf 2: %x\n\n", 44);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 3: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", 155);
i = printf("Printf 2: %x\n\n", 155);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", 356);
i = printf("Printf 2: %x\n\n", 356);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 5: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", 34242);
i = printf("Printf 2: %x\n\n", 34242);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 6: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", UINT_MAX);
i = printf("Printf 2: %x\n\n", UINT_MAX);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 7: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", -1);
i = printf("Printf 2: %x\n\n", -1);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 8: Hexa_Lower\n---------------\n\n", 1);
z = ft_printf("Printf 1: %x\n\n", -1525);
i = printf("Printf 2: %x\n\n", -1525);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 1: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", 0);
i = printf("Printf 2: %X\n\n", 0);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 2: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", 44);
i = printf("Printf 2: %X\n\n", 44);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 3: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", 155);
i = printf("Printf 2: %X\n\n", 155);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 4: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", 356);
i = printf("Printf 2: %X\n\n", 356);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 5: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", 34242);
i = printf("Printf 2: %X\n\n", 34242);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 6: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", UINT_MAX);
i = printf("Printf 2: %X\n\n", UINT_MAX);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 7: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", -1);
i = printf("Printf 2: %X\n\n", -1);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
ft_putstr_fd("Test 8: Hexa_Upper\n---------------\n\n", 1);
z = ft_printf("Printf 1: %X\n\n", -1525);
i = printf("Printf 2: %X\n\n", -1525);
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
z = ft_printf("asdasd%sadsad%dasdad%s\n\n", "HEllo", 5, "Name");
i = printf("asdasd%sadsad%dasdad%s\n\n", "HEllo", 5, "Name");
printf("Return: %d\n", z);
printf("Return: %d\n\n", i);
return (0);
}