-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_print_nbr.c
32 lines (29 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_nbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: awallet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/23 16:31:48 by awallet #+# #+# */
/* Updated: 2022/08/07 16:35:56 by awallet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "ft_printf.h"
int ft_print_nbr(int n, int fd)
{
long nb;
int len;
len = 0;
nb = n;
if (nb < 0)
{
len += ft_print_putchar_fd('-', fd);
nb *= -1;
}
if (nb >= 10)
len += ft_print_nbr(nb / 10, fd);
len += ft_print_putchar_fd((nb % 10) + '0', fd);
return (len);
}