Repository navigation
Expand file tree
/
Copy pathft_printf_support.c
More file actions
65 lines (58 loc) · 1.68 KB
/
Copy pathft_printf_support.c
File metadata and controls
65 lines (58 loc) · 1.68 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
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_support.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kalshaer <kalshaer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/30 21:55:57 by kalshaer #+# #+# */
/* Updated: 2022/10/05 14:14:55 by kalshaer ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf_countdigit(int d)
{
int r;
char *t;
t = ft_itoa(d);
r = ft_strlen(t);
free (t);
return (r);
}
void ft_printf_putusnbr(unsigned int u, int *i)
{
if (u > 9)
{
*i = *i + 1;
ft_printf_putusnbr(u / 10, i);
}
u = (u % 10) + 48;
write(1, &u, 1);
}
void ft_printf_printp(size_t p, int *i, char *base)
{
if (p >= 16)
{
*i = *i + 1;
ft_printf_printp(p / 16, i, "0123456789abcdef");
}
write(1, &base[p % 16], 1);
}
void ft_printf_printx(unsigned int x, int *i, char *base)
{
if (x >= 16)
{
*i = *i + 1;
ft_printf_printx(x / 16, i, "0123456789abcdef");
}
write(1, &base[x % 16], 1);
}
void ft_printf_printxx(unsigned int xx, int *i, char *base)
{
if (xx >= 16)
{
*i = *i + 1;
ft_printf_printxx(xx / 16, i, "0123456789ABCDEF");
}
write(1, &base[xx % 16], 1);
}