Improve main by implementing fmtsplit to split format into chunks and pass function pointer to compare ft_printf with printf

This commit is contained in:
gbaconni
2022-04-24 00:40:01 +02:00
parent 505f5d9912
commit d4fb946428
11 changed files with 236 additions and 271 deletions

View File

@@ -6,7 +6,7 @@
/* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/20 11:55:58 by gbaconni #+# #+# */
/* Updated: 2022/04/17 22:40:01 by gbaconni ### lausanne.ch */
/* Updated: 2022/04/24 00:29:57 by gbaconni ### lausanne.ch */
/* */
/* ************************************************************************** */
@@ -14,19 +14,24 @@
int ft_vprintf_percent(const char *format, va_list ap)
{
int ret;
const char *fmt;
int ret;
char c;
if (*format == '%')
ret = ft_vprintf_other(format, ap);
else if (*format == 'c')
ret = 0;
fmt = format + 1;
c = *(fmt + ft_skipchars(fmt, "0123456789# +"));
if (c == 'c')
ret = ft_vprintf_char(format, ap);
else if (*format == 's')
else if (c == 's')
ret = ft_vprintf_string(format, ap);
else if (*format == 'p')
else if (c == 'p')
ret = ft_vprintf_pointer(format, ap);
else if (*format == 'd' || *format == 'i' || *format == 'u')
ret = ft_vprintf_decimal(format, ap);
else if (*format == 'x' || *format == 'X')
else if (c == 'x' || c == 'X')
ret = ft_vprintf_hexadecimal(format, ap);
else if (c == 'd' || c == 'i' || c == 'u')
ret = ft_vprintf_decimal(format, ap);
else
ret = ft_vprintf_other(format, ap);
return (ret);
}