-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_puthexaup.c
57 lines (52 loc) · 1.37 KB
/
ft_puthexaup.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_puthexaup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: iel-moha <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/10 11:12:48 by iel-moha #+# #+# */
/* Updated: 2021/12/13 11:02:06 by iel-moha ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int len_u(unsigned int nb)
{
int i;
i = 0;
if (nb == 0)
return (i = 1);
while (nb > 0)
{
nb /= 16;
i++;
}
return (i);
}
int ft_puthexaup(unsigned int nb)
{
char c;
if (nb < 16)
{
if (nb < 10)
c = nb + '0';
else
c = nb + ('A' - 10);
write(1, &c, 1);
}
else
{
ft_puthexaup(nb / 16);
ft_puthexaup(nb % 16);
}
return (len_u(nb));
}
/*
int main()
{
int i;
i = ft_puthexaup(55555);
printf(" %i ", i);
i = printf(" %X ", 55555);
printf(" %i ", i);
}*/