ft_printf/srcs/ft_printf.c
2019-02-07 17:12:52 +01:00

37 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/07 13:31:16 by tmaze #+# #+# */
/* Updated: 2019/02/07 14:21:34 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libftprintf.h"
int ft_printf(const char *format, ...)
{
va_list ap;
size_t i;
size_t j;
t_flags flags;
static int (*convf[10])(t_flags *flags, va_list *ap) = {pf_convc,
pf_convs, pf_convp, pf_convd, pf_convi, pf_convo, pf_convu, pf_convx,
pf_convx, pf_convf};
va_start(ap, format);
i = 0;
while (format[i])
{
j = 0;
while (format[i + j] && format[i + j] != '%')
j++;
write(1, &format[i], j);
i += j;
j = pf_getflags(&format[i], &flags);
}
}