-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf_char_str.c
39 lines (34 loc) · 1.3 KB
/
ft_printf_char_str.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_char_str.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anebbou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/14 13:32:23 by anebbou #+# #+# */
/* Updated: 2024/11/18 14:02:44 by anebbou ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf_char_str(char specifier, va_list args)
{
if (specifier == 'c')
return (ft_printf_char(va_arg(args, int)));
if (specifier == 's')
return (ft_printf_str(va_arg(args, char *)));
return (0);
}
int ft_printf_char(char c)
{
ft_putchar_fd(c, 1);
return (1);
}
int ft_printf_str(char *str)
{
int len;
if (!str)
str = "(null)";
len = ft_strlen(str);
ft_putstr_fd(str, 1);
return (len);
}