-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintf_tool.c
More file actions
43 lines (38 loc) · 1.28 KB
/
printf_tool.c
File metadata and controls
43 lines (38 loc) · 1.28 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
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_tool.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zrdouane <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/13 18:15:04 by zrdouane #+# #+# */
/* Updated: 2021/12/13 18:15:06 by zrdouane ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void ft_putchar(char c, int *len)
{
write(1, &c, 1);
*len = *len + 1;
}
void ft_putstr(char *s, int *len)
{
int i;
i = 0;
if (!s)
{
*len += write(1, "(null)", 6);
return ;
}
while (s[i])
{
ft_putchar(s[i], len);
i++;
}
}
void ft_put_adress(unsigned long n, const char *base, int *len)
{
if (n >= 16)
ft_put_adress(n / 16, base, len);
ft_putchar(base[n % 16], len);
}