-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr_fd.c
40 lines (37 loc) · 1.21 KB
/
ft_putnbr_fd.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
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoudni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/30 16:20:37 by omoudni #+# #+# */
/* Updated: 2021/12/02 18:45:31 by omoudni ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
int pow;
long int nb;
long int nb_2;
pow = 1;
if (n < 0)
nb = -(long int)n;
else
nb = n;
nb_2 = nb;
while (nb_2 / 10)
{
pow *= 10;
nb_2 /= 10;
}
if (n < 0)
ft_putchar_fd('-', fd);
while (pow)
{
ft_putchar_fd(((nb / pow) + 48), fd);
nb %= pow;
pow /= 10;
}
}