-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr.c
36 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aarbaoui <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/23 10:51:56 by aarbaoui #+# #+# */
/* Updated: 2022/10/27 17:11:13 by aarbaoui ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putnbr(int nbr, int *len)
{
if (nbr > 2147483647 || nbr < -2147483648)
return ;
if (nbr == -2147483648)
{
ft_putstr("-2147483648", len);
return ;
}
if (nbr < 0)
{
nbr *= -1;
ft_putchar('-', len);
}
if (nbr < 10)
ft_putchar(nbr + '0', len);
else
{
ft_putnbr(nbr / 10, len);
ft_putchar((nbr % 10) + '0', len);
}
}