-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchooser.c
More file actions
41 lines (39 loc) · 751 Bytes
/
chooser.c
File metadata and controls
41 lines (39 loc) · 751 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
#include "main.h"
/**
* choice - function that will choose the function pointer
* @car: the format specifier
* @ar: va_list variable
* Return: Result of the choice
*/
int choice(va_list ar, char car)
{
choose great[] = {
{'c', myputchar},
{'s', _puts},
{'%', percent},
{'d', print_number},
{'i', print_number},
{'b', print_binary},
{'u', print_unsigned},
{'o', print_octal},
{'x', print_hex},
{'X', print_HEX},
{'p', print_ptr},
{'r', print_rev_string},
{'R', print_rot13}
/*{'S', print_ascii}*/
};
int iter = 0;
int count = 0;
int (*func)(va_list a);
for (iter = 0; iter < 13; iter++)
{
if (car == great[iter].c)
{
func = great[iter].f;
count += func(ar);
return (count);
}
}
return (-7);
}