-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_printf.c
41 lines (38 loc) · 1.38 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: made-ara <made-ara@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/03 12:53:00 by made-ara #+# #+# */
/* Updated: 2024/08/10 11:04:30 by made-ara ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(char const *format_string, ...)
{
va_list list_arg;
int len;
int i;
va_start(list_arg, format_string);
len = 0;
i = 0;
while (format_string[i])
{
if (format_string[i] == '%' && format_string[i + 1] == '\0')
{
return (-1);
}
else if (format_string[i] == '%' && format_string[i + 1] != '\0')
{
len += ft_toconvert(format_string[i + 1], list_arg);
i++;
}
else
len += ft_putchar(format_string[i]);
i++;
}
va_end (list_arg);
return (len);
}