-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr.c
More file actions
38 lines (35 loc) · 1.24 KB
/
ft_putnbr.c
File metadata and controls
38 lines (35 loc) · 1.24 KB
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
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_putnbr.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: thperchi <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/07/11 03:47:03 by thperchi #+# ## ## #+# */
/* Updated: 2018/10/10 18:21:50 by thperchi ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr(int nb)
{
int x;
x = nb;
if (x == -2147483648)
{
write(1, "-2147483648", 11);
}
else if (nb < 0)
{
ft_putchar('-');
x = x * -1;
ft_putnbr(x);
}
else if (x > 9)
{
ft_putnbr(x / 10);
ft_putnbr(x % 10);
}
else
ft_putchar(x + '0');
}