-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
40 lines (35 loc) · 1.18 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
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmattera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/12 11:08:37 by nmattera #+# #+# */
/* Updated: 2022/05/17 12:48:03 by nmattera ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);
}
void ft_putnbr_fd(int n, int fd)
{
long nb;
nb = n;
if (nb < 0)
{
nb *= -1;
ft_putchar_fd('-', fd);
}
if (nb > 9)
ft_putnbr_fd(nb / 10, fd);
ft_putchar_fd((nb % 10 + 48), fd);
}
/*
int main ()
{
ft_putnbr_fd(-12, 1);
}
*/