forked from Tahani-Saber/printf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_op_func.c
More file actions
40 lines (38 loc) · 722 Bytes
/
get_op_func.c
File metadata and controls
40 lines (38 loc) · 722 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
#include "main.h"
/**
* get_op_func - selects the correct function to perform
* the operation asked by the user.
*
* @specifier: operator.
*
* Return: pointer to function.
*/
int (*get_op_func(char specifier))(va_list, flags_t *)
{
op_t ops[] = {
{"c", print_char},
{"s", print_str},
{"%", print_100symbol},
{"r", print_rev},
{"R", print_rot13},
{"d", print_int},
{"i", print_int},
{"u", print_uint},
{"x", print_hex},
{"X", print_HEX},
{"o", print_octal},
{"b", print_bin},
{"S", print_STR},
{"p", print_ptr},
{NULL, NULL}
};
int index;
index = 0;
while (ops[index].op != NULL)
{
if (specifier == *ops[index].op)
return (ops[index].func);
index++;
}
return (NULL);
}