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
|
typedef struct s_opt
{
char ch;
int (*f)();
int va;
int fl;
} opt_t;
opt_t opt[] = {
{'c', my_printf_c, 1, 0},
{'s', my_printf_s, 1, 0},
{'d', my_printf_d, 1, 1},
{'i', my_printf_d, 1, 1},
{'u', my_printf_u, 1, 1},
{'b', my_printf_b, 1, 0},
{'S', my_printf_S, 1, 0},
{'%', my_printf_mod, 0, 0},
{'o', my_printf_o, 1, 0},
{0, 0, 0, 0}
};
char *optest(char *c, va_list *va, int *ctp)
{
int i;
int space;
int fl;
i = 0;
while (opt[i].ch != '\0')
{
if (*c == opt[i].ch)
{
opt[i].f(va, ctp);
return (c);
}
i++;
}
return (c);
} |
Partager