-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf.c
More file actions
36 lines (33 loc) · 1.3 KB
/
Copy pathft_printf.c
File metadata and controls
36 lines (33 loc) · 1.3 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tblochet <tblochet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/12 20:01:13 by tblochet #+# #+# */
/* Updated: 2024/12/11 20:25:08 by tblochet ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(char const *fmt, ...)
{
va_list args;
t_formatter fmtr;
int len;
if (!fmt)
return (-1);
va_start(args, fmt);
fmtr.err = 0;
fmtr.flags = 0;
ft_count_flags(fmt, &fmtr);
if (fmtr.n < 0)
return (-1);
ft_parse_flags(fmt, args, &fmtr);
len = ft_display_formatted(fmt, fmtr.flags);
if (fmtr.err || len < 0)
len = -1;
ft_lstclear(&fmtr.flags, free);
va_end(args);
return (len);
}