-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
40 lines (37 loc) · 1.31 KB
/
ft_printf.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/07 21:37:45 by alyildiz #+# #+# */
/* Updated: 2023/05/08 21:30:02 by alyildiz ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *str, ...)
{
va_list arguments;
size_t i;
size_t len;
int count;
i = 0;
count = 0;
if (!str)
return (-1);
len = ft_strlen(str);
va_start(arguments, str);
while (i < len)
{
if (str[i] == '%' && check(str[i + 1]) == 1)
{
count += flags(str[i + 1], arguments);
i += 2;
}
else if (str[i])
count += write(1, &str[i++], 1);
}
va_end(arguments);
return (count);
}