-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_printf.c
More file actions
49 lines (43 loc) · 734 Bytes
/
_printf.c
File metadata and controls
49 lines (43 loc) · 734 Bytes
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
#include "holberton.h"
/**
* _printf - copy of funtion boult.in printf
* @format: format
* Return: length of string
*/
int _printf(const char *format, ...)
{
va_list data;
int len_format, i, check_print = 0;
char letter;
i = len_format = 0;
va_start(data, format);
if (format == NULL)
return (-1);
for (i = 0; format[i] != '\0'; i++)
;
if (i == 0)
return (0);
i = 0;
while (*(format + i) != '\0')
{
if (*(format + i) != '%')
{
letter = format[i];
len_format += _write_char(letter);
}
else
{
check_print = find_match(data, format, i);
if (check_print == -1)
return (-1);
else
{
len_format += check_print;
i++;
}
}
i++;
}
va_end(data);
return (len_format);
}