-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
36 lines (33 loc) · 1.19 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: mesafi <mesafi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/06 00:38:46 by mesafi #+# #+# */
/* Updated: 2020/01/20 13:30:21 by mesafi ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
char b;
if (n < 0)
{
if (n <= -10)
ft_putnbr_fd(n / 10, fd);
else
write(fd, "-", 1);
b = (n % 10) * -1 + '0';
write(fd, &b, 1);
}
else
{
if (n >= 10)
ft_putnbr_fd(n / 10, fd);
b = (n % 10) + '0';
write(fd, &b, 1);
}
}