-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf_main.c
119 lines (99 loc) · 3.02 KB
/
ft_printf_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
#include "ft_printf.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
void test(void)
{
int ft;
int og;
void *ptr;
char *string = "Lala land!";
ptr = &string;
ft = ft_printf("FT This is a character: %c\n", 'X');
og = printf("OG This is a character: %c\n", 'X');
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is two characters: %c and: %c\n", 'X', 'Y');
og = printf("OG This is two characters: %c and: %c\n", 'X', 'Y');
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is a string: %s\n", "Hello World!");
og = printf("OG This is a string: %s\n", "Hello World!");
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is three strings: %s and: %s andand: %s\n", "Hello World!", "Second one...", "and a third one too :-)");
og = printf("OG This is three strings: %s and: %s andand: %s\n", "Hello World!", "Second one...", "and a third one too :-)");
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is an integer: %d\n", 42);
og = printf("OG This is an integer: %d\n", 42);
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is an integer: %i\n", -42);
og = printf("OG This is an integer: %i\n", -42);
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This zero int: %d\n", 0);
og = printf("OG This zero int: %d\n", 0);
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is zero hex int: %x\n", 0);
og = printf("OG This is zero hex int: %x\n", 0);
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is hex int: %x\n", 10);
og = printf("OG This is hex int: %x\n", 10);
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is a pointer: %p\n", ptr);
og = printf("OG This is a pointer: %p\n", ptr);
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
ft = ft_printf("FT This is a precentage sign: %%\n");
og = printf("OG This is a precentage sign: %%\n");
if (ft == og)
printf("Return value SUCCESS!\n");
else
printf("Return value FAIL! og: %d ft: %d\n", og, ft);
printf("\n");
}
*/
int main()
{
int x = printf("og: %x \n", -1);
int y = ft_printf("ft: %x \n", -1);
printf("og: %d, ft: %d\n", x, y);
// test();
return (0);
}