-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr.c
More file actions
39 lines (37 loc) · 1.19 KB
/
Copy pathft_putnbr.c
File metadata and controls
39 lines (37 loc) · 1.19 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
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mnishimo <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/27 10:06:11 by mnishimo #+# #+# */
/* Updated: 2019/01/12 22:26:52 by mnishimo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
void ft_putnbr(int n)
{
if (n == -2147483648)
{
ft_putstr("-2147483648");
return ;
}
if (n == 0)
{
ft_putchar('0');
return ;
}
if (n < 0)
{
ft_putchar('-');
n = -n;
}
if (n / 10 == 0)
{
ft_putchar(n % 10 + '0');
return ;
}
ft_putnbr(n / 10);
ft_putchar(n % 10 + '0');
}