-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathft_putnbr_fd.c
41 lines (37 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 15:58:24 by mihykim #+# #+# */
/* Updated: 2020/02/29 22:02:19 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Outputs the integer 'n' to the given file descriptor.
*/
void ft_putnbr_fd(int n, int fd)
{
if (n == -2147483648)
{
ft_putnbr_fd(-214748364, fd);
ft_putchar_fd('8', fd);
}
else if (n < 0)
{
ft_putchar_fd('-', fd);
ft_putnbr_fd(-n, fd);
}
else
{
if (n >= 10)
ft_putnbr_fd(n / 10, fd);
ft_putchar_fd(n % 10 + '0', fd);
}
}
/*
** line ?? : to solve Seg-falut
*/