-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr.c
34 lines (31 loc) · 1.15 KB
/
ft_putnbr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hshawand <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 09:38:39 by hshawand #+# #+# */
/* Updated: 2019/04/08 10:46:12 by hshawand ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int n)
{
unsigned int dec;
char digit;
dec = 1;
if (n < 0)
{
write(1, "-", 1);
n = -n;
}
while (n / dec / 10 > 0)
dec = dec * 10;
while (dec >= 1)
{
digit = n / dec % 10 + '0';
write(1, &digit, 1);
dec = dec / 10;
}
}