-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
35 lines (32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: xle-baux <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/29 15:28:05 by xle-baux #+# #+# */
/* Updated: 2021/11/29 15:48:06 by xle-baux ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
long int nbr;
nbr = n;
if (fd != -1)
{
if (nbr < 0)
{
nbr = nbr * -1;
ft_putchar_fd('-', fd);
}
if (nbr < 10)
ft_putchar_fd(nbr + '0', fd);
else if (nbr >= 10)
{
ft_putnbr_fd(nbr / 10, fd);
ft_putnbr_fd(nbr % 10, fd);
}
}
}