-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr.c
35 lines (32 loc) · 1.15 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbouderr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/11 18:26:11 by mbouderr #+# #+# */
/* Updated: 2022/11/11 21:39:56 by mbouderr ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr(long i)
{
int count;
count = 0;
if (i < 0)
{
i *= -1;
count += ft_putchar('-');
}
if (i > 9)
{
count += ft_putnbr(i / 10);
count += ft_putnbr(i % 10);
}
if (i >= 0 && i <= 9)
{
count += ft_putchar(i + 48);
}
return (count);
}