-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintf.c
More file actions
37 lines (34 loc) · 816 Bytes
/
Copy pathprintf.c
File metadata and controls
37 lines (34 loc) · 816 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
#include "main.h"
/**
* _printf - This takes in the string as argument and prints out
* the appropriate format
* @format: string to be taken as argument
* Return: total number of characters printed to stdout
*/
int _printf(const char *format, ...)
{
int total_print;
f_spec f_list[] = {
{"c", print_c},
{"s", print_str},
{"%", print_percent},
{"d", print_int},
{"i", print_int},
{"b", print_bin},
{"x", print_hex},
{"X", print_HEX},
{"o", print_oct},
{"u", print_unsigned},
{"R", rot13},
{"r", print_rev},
{NULL, NULL}
};
va_list args_list;
if (format == NULL)
return (-1);
va_start(args_list, format);
/* function (format_printer) returns the total number printed */
total_print = format_specifier(format, f_list, args_list);
va_end(args_list);
return (total_print);
}