-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr.c
37 lines (34 loc) · 1.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ssalaues <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 14:31:51 by ssalaues #+# #+# */
/* Updated: 2016/12/11 21:44:35 by ssalaues ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr(int n)
{
char *min;
long nb;
nb = n;
min = "-2147483648";
if (nb == -2147483648)
while (*min)
write(1, min++, 1);
if (nb < 0 && nb != -2147483648)
{
nb = -nb;
write(1, "-", 1);
}
if (nb > 9 && nb != -2147483648)
{
ft_putnbr(nb / 10);
ft_putnbr(nb % 10);
}
else if (nb != -2147483648)
ft_putchar(nb + '0');
}