-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr_fd.c
44 lines (42 loc) · 1.32 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
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rhiguita <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/24 23:37:45 by rhiguita #+# #+# */
/* Updated: 2024/03/12 01:38:38 by rhiguita ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int *i)
{
if (n == -2147483648)
{
ft_putstr_fd("-2147483648", i);
return ;
}
if (n < 0 && n != -2147483648)
{
ft_putchar_fd('-', i);
n = -n;
}
if (n >= 10)
{
ft_putnbr_fd(n / 10, i);
n %= 10;
}
if (n != -2147483648)
ft_putchar_fd(n % 10 + '0', i);
}
/*
#include <fcntl.h>
int main(void)
{
int fd = open("text.txt", O_RDWR);
int num = 123;
ft_putnbr_fd(num, fd);
close(fd);
return (0);
}*/