-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintf_side.c
50 lines (45 loc) · 1.48 KB
/
printf_side.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_side.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tekim <tekim@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/17 16:32:23 by tekim #+# #+# */
/* Updated: 2021/06/22 15:59:01 by tekim ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void info_value(t_info *info)
{
info->minus = 0;
info->zero = 0;
info->width = 0;
info->prec = -1;
info->type = 0;
info->nbr_base = 10;
info->is_negative = 0;
}
int ft_numlen(unsigned long long nbr, t_info *info)
{
int i;
if (nbr == 0 && info->prec != 0)
return (1);
i = 0;
while (nbr)
{
nbr /= info->nbr_base;
i++;
}
return (i);
}
char *ft_baseset(char type)
{
if (type == 'u' || type == 'd' || type == 'i')
return ("0123456789");
else if (type == 'x' || type == 'p')
return ("0123456789abcdef");
else if (type == 'X')
return ("0123456789ABCDEF");
return (0);
}