-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
36 lines (31 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: mriant <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/03 17:36:32 by mriant #+# #+# */
/* Updated: 2021/12/04 12:00:48 by mriant ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void ft_printnbr_fd(long int n, int fd)
{
char c;
if (n / 10 != 0)
ft_printnbr_fd(n / 10, fd);
c = (n % 10) + '0';
ft_putchar_fd(c, fd);
}
void ft_putnbr_fd(int n, int fd)
{
long int nb;
nb = (long int)n;
if (n < 0)
{
nb = -nb;
ft_putchar_fd('-', fd);
}
ft_printnbr_fd(nb, fd);
}