-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf_utils.c
More file actions
54 lines (47 loc) · 1.41 KB
/
Copy pathft_printf_utils.c
File metadata and controls
54 lines (47 loc) · 1.41 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
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: licohen <licohen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/07 13:21:33 by licohen #+# #+# */
/* Updated: 2024/06/10 20:24:34 by licohen ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_print_putchar(char c)
{
return (write(1, &c, 1));
}
int ft_printf_putstr(char *str)
{
int len;
len = 0;
if (!str)
str = "(null)";
while (str[len])
{
ft_print_putchar(str[len]);
len++;
}
return (len);
}
int ft_strlen(char *str)
{
int len;
len = 0;
if (!str)
return (0);
while (str[len])
len++;
return (len);
}
int ft_p(void *ptr)
{
if (ptr == NULL)
return (ft_printf_putstr("(nil)"));
else
return (ft_printf_putstr("0x") + ft_count_unsigned((unsigned long)ptr,
"0123456789abcdef"));
}