-
Notifications
You must be signed in to change notification settings - Fork 4
/
ft_putnbr_fd.c
25 lines (23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ykoh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/17 23:54:42 by ykoh #+# #+# */
/* Updated: 2020/08/17 17:24:55 by ykoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
if (n < 0)
ft_putchar_fd('-', fd);
if (n == INT_MIN)
return (ft_putstr_fd("2147483648", fd));
n = (n < 0) ? -n : n;
if (n > 9)
ft_putnbr_fd(n / 10, fd);
ft_putchar_fd("0123456789"[n % 10], fd);
}