-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_put.c
91 lines (80 loc) · 1.72 KB
/
ft_put.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_put.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akdemir <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/15 21:38:32 by akdemir #+# #+# */
/* Updated: 2023/07/27 17:53:41 by akdemir ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_puts(char *s)
{
int l;
int i;
l = 0;
i = 0;
if (!s)
{
l += ft_puts("(null)");
return (l);
}
while (s[i])
{
l += ft_putc(s[i]);
i++;
}
return (l);
}
int ft_putu(unsigned int u)
{
int l;
l = 0;
if (u < 10)
l += ft_putc(u + '0');
else
{
l += ft_putu(u / 10);
l += ft_putu(u % 10);
}
return (l);
}
int ft_putn(int n)
{
long nbr;
int l;
l = 0;
nbr = n;
if (nbr < 0)
{
l += ft_putc('-');
nbr *= -1;
}
if (nbr < 10)
l += ft_putc(nbr + '0');
else
{
l += ft_putn(nbr / 10);
l += ft_putn(nbr % 10);
}
return (l);
}
int ft_puth(unsigned long h, char *p)
{
int l;
l = 0;
if (h >= 16)
l += ft_puth(h / 16, p);
l += ft_putc(p[h % 16]);
return (l);
}
int ft_putp(void *p)
{
int l;
l = 0;
l += ft_puts("0x");
l += ft_puth((unsigned long)p, "0123456789abcdef");
return (l);
}