From eca117f28afac2ee258d9e9454ff63c6dec5b58f Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 4 Nov 2019 01:34:37 +0100 Subject: int type length specifier, edge case with zero padding and invalid wildcard precision --- ft_printf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ft_printf.c') diff --git a/ft_printf.c b/ft_printf.c index d71f397..40bc89d 100644 --- a/ft_printf.c +++ b/ft_printf.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/29 00:15:28 by cacharle #+# #+# */ -/* Updated: 2019/10/31 00:10:04 by cacharle ### ########.fr */ +/* Updated: 2019/11/04 00:28:38 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,6 +33,8 @@ int ft_printf(const char *format, ...) va_start(ap, format); print_len = 0; i = -1; + /* int *a = NULL; */ + /* printf("%d", *a); */ while (format[++i]) { if (format[i] != '%') @@ -44,7 +46,8 @@ int ft_printf(const char *format, ...) str = convert(flist->content, ap); if (str == NULL && flist->content->type == 'n') { - *flist->content->written = print_len; + if (flist->content->written != NULL) + *flist->content->written = print_len; i += flist->content->fmt_len; list_pop_front(&flist); continue; @@ -54,7 +57,6 @@ int ft_printf(const char *format, ...) list_destroy(&flist); return (-1); } - printf("\n%c\n", flist->content->type); if (flist->content->type == 'c') { write(1, str, flist->content->size); @@ -63,7 +65,6 @@ int ft_printf(const char *format, ...) } else { - ft_putstr(str); print_len += ft_strlen(str); free(str); @@ -73,7 +74,7 @@ int ft_printf(const char *format, ...) } list_destroy(&flist); va_end(ap); - return (print_len + i); + return (print_len); } char *ft_strappend(char *dest, char *src) -- cgit