-
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 (44 loc) · 1.3 KB
/
ft_putnbr_fd.c
File metadata and controls
47 lines (44 loc) · 1.3 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: sudaniel <sudaniel@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/11 14:29:52 by sudaniel #+# #+# */
/* Updated: 2024/10/11 17:34:14 by sudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
unsigned int digit;
unsigned int temp;
int power;
power = 1;
if (n < 0)
{
write(fd, "-", 1);
temp = -n;
}
else
temp = n;
while (temp / power > 9)
power *= 10;
while (power > 0)
{
digit = temp / power + '0';
write(fd, &digit, 1);
temp %= power;
power /= 10;
}
}
/*
int main(void)
{
int n = 42;
ft_putnbr_fd(n, 1);
putchar('\n');
return (0);
}
*/