-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printfhexlow.c
More file actions
53 lines (48 loc) · 1.47 KB
/
ft_printfhexlow.c
File metadata and controls
53 lines (48 loc) · 1.47 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printfhexlow.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eagoumi <eagoumi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/16 04:26:35 by eagoumi #+# #+# */
/* Updated: 2022/11/16 04:26:35 by eagoumi ### ########.fr */
/* */
/* ************************************************************************** */
#include "./ft_printf.h"
int ft_printfhexlow(unsigned int nbr)
{
char *base_16;
int len;
base_16 = "0123456789abcdef";
len = 0;
if (nbr < 16)
{
write(1, &base_16[nbr], 1);
len++;
}
else
{
len += ft_printfhexlow(nbr / 16);
len += ft_printfhexlow(nbr % 16);
}
return (len);
}
int ft_printfadd(unsigned long nbr)
{
char *base_16;
int len;
base_16 = "0123456789abcdef";
len = 0;
if (nbr < 16)
{
write(1, &base_16[nbr], 1);
len++;
}
else
{
len += ft_printfadd(nbr / 16);
len += ft_printfadd(nbr % 16);
}
return (len);
}