-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr_fd.c
More file actions
47 lines (46 loc) · 1.33 KB
/
Copy pathft_putnbr_fd.c
File metadata and controls
47 lines (46 loc) · 1.33 KB
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
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yelallam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/27 09:28:24 by yelallam #+# #+# */
/* Updated: 2025/12/01 17:26:18 by yelallam ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr_fd(int n, int fd)
{
int count, (num);
count = 0;
if (n == 0)
count++;
if (n < 0)
{
if (n == -2147483648)
{
write(1, "-2147483648", 11);
return (11);
}
write(fd, "-", 1);
count++;
n = -n;
}
num = n;
while (num > 0)
{
num /= 10;
count++;
}
if (n > 9)
ft_putnbr_fd(n / 10, fd);
ft_putchar_fd(n % 10 + '0', 1);
return (count);
}
/*int main()
{
int i;
i = ft_putnbr_fd(0, 1);
printf("\n%d", i);
}*/