-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr_fd.c
executable file
·42 lines (39 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
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ichubare <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 19:15:41 by ichubare #+# #+# */
/* Updated: 2017/05/08 13:50:31 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
void ft_putnbr_fd(int n, int fd)
{
char buf[12];
char *res;
res = buf;
res += 11;
if (n == 0)
ft_putchar_fd('0', fd);
if (n >= 0)
{
while (n != 0)
{
*--res = '0' + (n % 10);
n /= 10;
}
}
else
{
while (n != 0)
{
*--res = '0' - (n % 10);
n /= 10;
}
*--res = '-';
}
ft_putstr_fd(res, fd);
}