-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_putnbr_fd.c
33 lines (29 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abello-r <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/13 12:49:42 by abello-r #+# #+# */
/* Updated: 2020/01/13 14:41:14 by abello-r ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void ft_putchar(char x, int fd)
{
write(fd, &x, 1);
}
void ft_putnbr_fd(int n, int fd)
{
int long i;
i = n;
if (i < 0)
{
write(fd, "-", 1);
i = i * -1;
}
if (i > 9)
ft_putnbr_fd(i / 10, fd);
ft_putchar(i % 10 + 48, fd);
}