-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_print_string.c
More file actions
42 lines (37 loc) · 1.27 KB
/
ft_print_string.c
File metadata and controls
42 lines (37 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_string.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vpogorel <vpogorel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/30 13:59:29 by vpogorel #+# #+# */
/* Updated: 2024/12/05 17:09:38 by vpogorel ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
static void ft_putstr_fd(char *s, int fd, int *count)
{
int i;
i = 0;
if (s == NULL)
return ;
while (s[i])
{
write(fd, &s[i], 1);
i++;
}
(*count) += i;
}
void ft_print_string(va_list args, int *count)
{
char *result;
result = va_arg(args, char *);
if (result == NULL)
{
write(1, "(null)", 6);
(*count) += 6;
return ;
}
ft_putstr_fd(result, 1, count);
}