-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putnbr_fd.c
34 lines (31 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kypark <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/04 21:51:46 by kypark #+# #+# */
/* Updated: 2020/11/04 21:54:21 by kypark ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
long int number;
char c;
c = '0';
number = n;
if (number < 0)
{
number = number * -1;
write(fd, "-", 1);
}
if (number > 9)
{
ft_putnbr_fd(number / 10, fd);
ft_putchar_fd((number % 10) + c, fd);
}
else
ft_putchar_fd(number + c, fd);
}