-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_putnbr.c
More file actions
38 lines (35 loc) · 1.22 KB
/
ft_putnbr.c
File metadata and controls
38 lines (35 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: slargo-b <slargo-b@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 12:24:23 by slargo-b #+# #+# */
/* Updated: 2025/02/07 13:13:03 by slargo-b ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putnbr(int n)
{
int count;
count = 0;
if (n == -2147483648)
{
count += ft_putstr("-2147483648");
return (count);
}
if (n < 0)
{
count += ft_putchar('-');
n = -n;
}
if (n >= 10)
{
count += ft_putnbr(n / 10);
count += ft_putchar(n % 10 + '0');
}
else
count += ft_putchar(n + '0');
return (count);
}