-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_function.c
More file actions
33 lines (28 loc) · 797 Bytes
/
Copy pathget_function.c
File metadata and controls
33 lines (28 loc) · 797 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
#include "main.h"
/**
* find_format_handlers- function is responsible for identifying formats
* intended for use with _printf.
* It then calls the appropriate corresponding function based on
* the identified format.
* @format: The format specifier (char, string, int, decimal, etc)
* Return: Either NULL or the associated function pointer.
*/
int (*find_format_handlers(const char *format))(va_list arg)
{
format_handler find_func[] = {
{"c", print_spec_c_match},
{"d", print_spec_d_match},
{"s", print_spec_s_match},
{"%", print_percent},
{NULL, NULL}
};
unsigned int i;
i = 0;
while (find_func[i].format_char)
{
if (format[0] == find_func[i].format_char[0])
return (find_func[i].handler_func);
i++;
}
return (NULL);
}