-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_print_nbr.c
35 lines (32 loc) · 1.21 KB
/
ft_print_nbr.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_print_nbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ebouabba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/08 22:48:42 by ebouabba #+# #+# */
/* Updated: 2021/12/10 16:14:35 by ebouabba ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_print_nbr(int n)
{
int count;
count = 0;
if (n == -2147483648)
return (ft_print_string("-2147483648"));
if (n < 0)
{
n = -n;
count = ft_print_char('-');
}
if (n <= 9)
count += ft_print_char(n + '0');
else
{
count += ft_print_nbr(n / 10);
count += ft_print_nbr(n % 10);
}
return (count);
}