-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr.c
39 lines (34 loc) · 1.18 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
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: blavonne <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/17 17:59:00 by blavonne #+# #+# */
/* Updated: 2019/09/17 19:05:58 by blavonne ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void ft_putnbr_rec(long long int nb)
{
int c;
if (nb > 9)
ft_putnbr_rec(nb / 10);
nb = nb % 10;
c = (int)nb + '0';
write(1, &c, 1);
}
void ft_putnbr(int n)
{
long long int nb;
if (n < 0)
{
nb = n;
nb = -nb;
ft_putchar('-');
}
else
nb = n;
ft_putnbr_rec(nb);
}