-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
40 lines (37 loc) · 1.17 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: asoler <asoler@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/12 15:51:44 by asoler #+# #+# */
/* Updated: 2022/04/12 21:44:34 by asoler ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
long int n2;
char aux[11];
int i;
i = 0;
n2 = n;
if (n2 < 0)
{
write(fd, "-", 1);
n2 *= -1;
}
while (n2 > 9)
{
aux[i] = (n2 % 10) + 48;
n2 /= 10;
i++;
}
aux[i] = n2 + 48;
while (i >= 0)
{
write(fd, &aux[i], 1);
i--;
}
}