-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_text.c
42 lines (38 loc) · 1.25 KB
/
ft_text.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_text.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: antandre <antandre@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/10 11:30:27 by antandre #+# #+# */
/* Updated: 2024/07/16 17:45:14 by antandre ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_putchar(char ch, int *len)
{
if (write(1, &ch, 1) == -1)
return (-1);
(*len)++;
return (0);
}
int ft_putstr(char *args, int *len)
{
size_t i;
i = 0;
if (!args)
{
if (write(1, "(null)", 6) == -1)
return (-1);
(*len) += 6;
return (0);
}
while (args[i])
{
if (ft_putchar(args[i], len) == -1)
return (-1);
i++;
}
return (0);
}