-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr.c
More file actions
39 lines (36 loc) · 1.2 KB
/
ft_putnbr.c
File metadata and controls
39 lines (36 loc) · 1.2 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: miissa <miissa@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/18 10:32:16 by miissa #+# #+# */
/* Updated: 2025/11/18 10:32:16 by miissa ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr(int n)
{
int count;
count = 0;
if (n == -2147483648)
{
return (write(1, "-2147483648", 11));
}
if (n < 0)
{
count += write(1, "-", 1);
n = -n;
}
if (n > 9)
{
count += ft_putnbr(n / 10);
count += ft_putnbr(n % 10);
}
else
{
count += ft_putchar(n + '0');
}
return (count);
}