-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbr.c
36 lines (33 loc) · 1.16 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
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aelsayed <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/26 18:29:59 by aelsayed #+# #+# */
/* Updated: 2025/01/26 21:25:31 by aelsayed ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr(int n)
{
char c;
if (n == -2147483648)
write(1, "-2147483648", 11);
else if (n >= 0 && n <= 9)
{
c = n + 48;
write(1, &c, 1);
}
else if (n < 0)
{
write(1, "-", 1);
ft_putnbr(-n);
}
else
{
ft_putnbr(n / 10);
ft_putnbr(n % 10);
}
}