-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr.c
More file actions
41 lines (38 loc) · 1.21 KB
/
ft_putnbr.c
File metadata and controls
41 lines (38 loc) · 1.21 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ipresno- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/05 12:50:05 by ipresno- #+# #+# */
/* Updated: 2022/09/05 13:27:35 by ipresno- ### ########.fr */
/* */
/* ************************************************************************** */
#include<unistd.h>
void ft_putchar(char c)
{
write (1, &c, 1);
}
void ft_putnbr(int n)
{
if (n == -2147483648)
{
ft_putchar('-');
ft_putchar('2');
ft_putnbr(147483648);
}
else if (n < 0)
{
ft_putchar('-');
n *= -1;
ft_putnbr(n);
}
else if (n < 10)
ft_putchar(n + '0');
else
{
ft_putnbr(n / 10);
ft_putnbr(n % 10);
}
}