-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printuint.c
60 lines (49 loc) · 1.62 KB
/
ft_printuint.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printuint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mriant <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/18 15:53:30 by mriant #+# #+# */
/* Updated: 2022/01/19 14:13:10 by mriant ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_printuint(t_llui n, int *result, char *base, int len)
{
char c;
if (n / len != 0)
ft_printuint(n / len, result, base, len);
c = base[(n % len)];
*result += ft_putchar_int(c);
}
int ft_putpoint(intptr_t n)
{
int result;
result = 0;
result += ft_putstr_int("0x");
ft_printuint(n, &result, "0123456789abcdef", 16);
return (result);
}
int ft_putuint(unsigned int n)
{
int result;
result = 0;
ft_printuint(n, &result, "0123456789", 10);
return (result);
}
int ft_putx(unsigned int n)
{
int result;
result = 0;
ft_printuint(n, &result, "0123456789abcdef", 16);
return (result);
}
int ft_putxmaj(unsigned int n)
{
int result;
result = 0;
ft_printuint(n, &result, "0123456789ABCDEF", 16);
return (result);
}