-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
executable file
·36 lines (33 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ioleksiu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/20 17:25:37 by ioleksiu #+# #+# */
/* Updated: 2016/12/20 20:37:04 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
char c;
unsigned int z;
z = n;
if (n < 0)
{
write(fd, "-", 1);
z = -z;
}
if (z >= 10)
{
ft_putnbr_fd(z / 10, fd);
ft_putnbr_fd(z % 10, fd);
}
else
{
c = z + 48;
write(fd, &c, 1);
}
}