-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_putnbr_fd.c
35 lines (32 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sel-mlil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/28 06:37:47 by sel-mlil #+# #+# */
/* Updated: 2024/11/01 13:39:06 by sel-mlil ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
unsigned int np;
if (fd < 0)
return ;
if (n < 0)
{
ft_putchar_fd('-', fd);
np = (unsigned int)(n * -1);
}
else
np = (unsigned int)(n);
if (np <= 9)
ft_putchar_fd(np + '0', fd);
else
{
ft_putnbr_fd((np / 10), fd);
ft_putchar_fd((np % 10) + '0', fd);
}
}