-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
41 lines (38 loc) · 1.46 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: ***REMOVED*** <***REMOVED***@student.***REMOVED***.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/12 15:54:32 by ***REMOVED*** #+# #+# */
/* Updated: 2023/10/19 12:42:37 by ***REMOVED*** ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *first_arg, ...)
{
va_list args;
t_pf_data *data;
int letter_count;
va_start(args, first_arg);
data = malloc(sizeof(t_pf_data));
if (!data)
return (-1);
data->arguments = &args;
data->letter_count = 0;
data->string_position = first_arg;
data->min_width = 0;
data->error = 0;
while (*(data->string_position) && !data->error)
ft_check_char(data);
va_end(args);
letter_count = (int)data->letter_count;
if (data->error)
{
free(data);
return (-1);
}
free(data);
return (letter_count);
}