-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_signed.c
44 lines (38 loc) · 1.23 KB
/
print_signed.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
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_signed.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: damartin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 14:58:36 by damartin #+# #+# */
/* Updated: 2022/05/04 14:58:38 by damartin ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
char *ft_itoa(int n);
int total_digits(int n);
int printnbr(int nb)
{
int total;
char *str;
str = ft_itoa(nb);
total = printstr(str);
free(str);
return (total);
}
int total_digits(int n)
{
int digits;
digits = 0;
if (n == 0)
digits++;
if (n < 0)
digits++;
while (n > 0)
{
n /= 10;
digits++;
}
return (digits);
}