-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_format_di.c
42 lines (37 loc) · 1.18 KB
/
ft_format_di.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_d.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: roudouch <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/22 13:50:34 by roudouch #+# #+# */
/* Updated: 2021/11/22 13:50:35 by roudouch ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static int count_ret(long num)
{
int i;
if (num == 0)
return (1);
i = 0;
if (num < 0)
{
num *= -1;
i++;
}
while (num > 0)
{
num /= 10;
i++;
}
return (i);
}
int ft_di(va_list ptr, int fd)
{
long nb;
nb = va_arg(ptr, int);
ft_putnbr(nb, fd);
return (count_ret(nb));
}