-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_print_strs.c
61 lines (53 loc) · 1.36 KB
/
ft_print_strs.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_strs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mrichard <mrichard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/04 22:13:46 by mrichard #+# #+# */
/* Updated: 2022/11/18 16:13:09 by mrichard ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_print_chr(int c)
{
write(1, &c, 1);
return (1);
}
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
{
write(1, &str[i], 1);
i++;
}
}
int ft_print_str(char *str)
{
int i;
i = 0;
if (str == NULL)
{
ft_putstr("(null)");
return (6);
}
while (str[i])
{
write(1, &str[i], 1);
i++;
}
return (i);
}
int ft_print_num(int n)
{
int len;
char *num;
len = 0;
num = ft_itoa(n);
len = ft_print_str(num);
free(num);
return (len);
}