-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf.c
41 lines (38 loc) · 1.25 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
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ayhamdou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/26 17:02:49 by ayhamdou #+# #+# */
/* Updated: 2023/12/10 18:10:52 by ayhamdou ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *str, ...)
{
int i;
int len;
va_list args;
if (!str)
return (0);
if (write(1, "stdout closed", 13) == -1)
return (-1);
i = 0;
va_start(args, str);
len = 0;
while (str[i])
{
if (str[i] == '%')
{
i++;
checker(str, args, &len, i);
}
else
len += ft_putchar(str[i]);
i++;
}
va_end(args);
return (len);
}