-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_printf.c
More file actions
55 lines (51 loc) · 1.51 KB
/
ft_printf.c
File metadata and controls
55 lines (51 loc) · 1.51 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
43
44
45
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erigolon <erigolon@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/09 15:13:38 by erigolon #+# #+# */
/* Updated: 2023/04/26 11:56:28 by erigolon ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_printf(char const *ph, ...)
{
int num_args;
va_list args;
int i;
int count;
if (write(1, "", 0) == -1)
return (-1);
num_args = ft_strlen(ph);
va_start(args, ph);
i = 0;
count = 0;
while (i < num_args)
{
if (ph[i] == '%')
{
i++;
count = ft_check_percentage(ph[i], args, count);
}
else
count += ft_putcharf(ph[i]);
i++;
}
va_end(args);
return (count);
}
/*
int main(void)
{
int result;
int myresult;
result = printf("Hola como %d estas\n", 0);
myresult = ft_printf("Hola como %d estas\n", 0);
printf("-----\n");
printf("%d\n", result);
printf("%d\n", myresult);
return (0);
}
*/