int ft_printf(const char *format, ...) { int count; int i; va_list ap; count = 0; i = 1; va_start(ap, format); while (format[i - 1]) { if ((format[i - 1] != '%' || (format[i - 1] == '%' && format[i] == '%')) && format[i - 1]) { count += ft_putchar(format[i - 1]); i++; } else if (ft_strchr("csndifxXpoEebulLztT#", format[i])) ft_flags1(format, &ap, &i, &count); else if (ft_strchr("*.+$^123456789", format[i])) ft_flags2(format, &ap, &i, &count); else i++; } va_end(ap); return (count); }
static void ft_opt2(const char *form, va_list *ap, int *i, int *count) { int j; va_list apcpy; j = 0; va_copy(apcpy, *ap); (*i)++; while (ft_strchr(".* 0123456789", form[*i])) { j++; (*i)++; } ft_opt2_b(form, apcpy, i, count); *i -= j; if (ft_strchr(".*+", form[*i])) ft_flags2(form, ap, i, count); else ft_flags1(form, ap, i, count); }