-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
36 lines (34 loc) · 1.19 KB
/
ft_putnbr_fd.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: belkarto <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/13 10:38:03 by belkarto #+# #+# */
/* Updated: 2022/10/31 17:54:05 by belkarto ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_putnbr_fd(int n, int fd)
{
long int nbr;
int i;
i = 0;
nbr = n;
if (nbr < 0)
{
i = 1;
ft_putchar_fd('-', fd);
nbr *= -1;
}
if (nbr > 9)
{
ft_putnbr_fd(nbr / 10, fd);
ft_putchar_fd(nbr % 10 + 48, fd);
}
else
ft_putchar_fd(nbr % 10 + 48, fd);
i += ft_intlen(nbr);
return (i);
}