-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf.c
More file actions
42 lines (39 loc) · 1.26 KB
/
ft_printf.c
File metadata and controls
42 lines (39 loc) · 1.26 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
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yel-mota <yel-mota@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/12 16:43:25 by yel-mota #+# #+# */
/* Updated: 2024/12/29 16:34:49 by yel-mota ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(const char *str, ...)
{
int i;
int cont;
int j;
if (str == NULL)
return (-1);
va_list(one);
va_start(one, str);
i = 0;
cont = 0;
while (str[i] != '\0')
{
if (str[i] == '%')
{
j = ft_putone(one, str[++i]);
if (j == -1)
return (-1);
cont += j;
}
else
cont += ft_putchar(str[i]);
i++;
}
va_end(one);
return (cont);
}