-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_count.c
37 lines (32 loc) · 1.24 KB
/
ft_putnbr_count.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_count.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asibille <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/19 13:05:14 by asibille #+# #+# */
/* Updated: 2022/01/19 13:05:16 by asibille ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static size_t ft_find_div_bis(size_t u)
{
size_t div;
div = 10;
while (u / div)
div *= 10;
return (div / 10);
}
void ft_putnbr_count(size_t u, int fd, int *size)
{
size_t div;
div = ft_find_div_bis(u);
while (div > 1)
{
ft_putchar_count((u / div) + '0', fd, size);
u = u % div;
div = div / 10;
}
ft_putchar_count(u + '0', fd, size);
}