-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfn_flow.c
50 lines (45 loc) · 794 Bytes
/
fn_flow.c
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
50
#include "main.h"
#include <stdlib.h>
#include <stdio.h>
/**
* fn_control - takes a flag and the argument and calls the
* appropriate function to print
*
* @s: the format specifier
* @ap: the list of the passed arguments
*
* Return: the number of chars printed (int)
*/
int fn_control(const char *s, va_list ap)
{
fn_ops ops[] = {
{'c', _char},
{'s', _string},
{'d', _int},
{'i', _int},
{'b', _bin},
{'r', _rev},
{0, NULL}
};
int i = 0;
int chars_printed = 0;
while (ops[i].specifier)
{
if (*s == ops[i].specifier)
chars_printed += ops[i].control(ap);
i++;
}
/**
*if (chars_printed == 0)
*{
* _putchar('z');
* _putchar('%');
* _putchar(*s);
* chars_printed += 2;
*}
*/
/**
* printf("cp:%d\n", chars_printed);
*/
return (chars_printed);
}