-
Notifications
You must be signed in to change notification settings - Fork 0
/
printf_utils.c
60 lines (53 loc) · 1.53 KB
/
printf_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hyeyukim <hyeyukim@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/09 12:07:37 by hyeyukim #+# #+# */
/* Updated: 2022/08/09 14:44:18 by hyeyukim ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void init_option(t_option *opt)
{
opt->flag = 0;
opt->width = 0;
opt->precision = 0;
opt->padding = ' ';
opt->out = 0;
opt->len = 0;
}
int find_flag(const char c, unsigned char *flag)
{
const char flags[5] = {'-', '+', ' ', '#', '0'};
int i;
i = -1;
while (++i < 5)
{
if (flags[i] == c)
{
*flag |= 1 << i;
return (1);
}
}
return (0);
}
int find_identifier(const char c)
{
const char identifiers[9] = {'c', 's', 'p', 'd', 'i', 'u', 'x', 'X', '%'};
int i;
i = -1;
while (++i < 9)
if (identifiers[i] == c)
return (i);
return (-1);
}
int ft_max(int a, int b)
{
if (a >= b)
return (a);
else
return (b);
}