-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_digit.c
39 lines (36 loc) · 1.18 KB
/
ft_digit.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
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_digit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aeminian <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/11 14:41:18 by aeminian #+# #+# */
/* Updated: 2024/03/10 19:57:13 by aeminian ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_digit(int n)
{
int count;
count = ft_count(n);
if (n == INT_MIN)
{
ft_putchar('-');
ft_putchar('2');
n = 147483648;
}
if (n < 0)
{
write(1, "-", 1);
n *= -1;
}
if (n >= 10)
{
ft_digit(n / 10);
n = n % 10;
}
if (n < 10)
ft_putchar(n + 48);
return (count);
}