-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_putnbr.c
36 lines (33 loc) · 1.14 KB
/
ft_putnbr.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: roudouch <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/12 10:45:59 by roudouch #+# #+# */
/* Updated: 2021/11/12 10:46:02 by roudouch ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putnbr(int n, int fd)
{
long nb;
char number;
nb = n;
if (nb < 0)
{
write(fd, "-", 1);
nb *= -1;
}
if (nb > 9)
{
ft_putnbr(nb / 10, fd);
ft_putnbr(nb % 10, fd);
}
else
{
number = nb + '0';
write(fd, &number, 1);
}
}