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:43:52 by gbaconni #+# #+# */
/* Updated: 2022/04/18 09:01:19 by gbaconni ### lausanne.ch */
/* Updated: 2022/04/24 00:36:07 by gbaconni ### lausanne.ch */
/* */
/* ************************************************************************** */
@@ -14,18 +14,21 @@
int ft_vprintf(char const *format, va_list ap)
{
int ret;
int ret;
const char *fmt;
ret = 0;
while (*format != 0)
fmt = format;
while (*fmt != 0)
{
if (*format == '%')
ret += ft_vprintf_percent(++format, ap);
else if (*format == '\\')
ret += ft_vprintf_escape(++format, ap);
if (*fmt == '%')
{
fmt++;
ret += ft_vprintf_percent(fmt, ap);
}
else
ret += ft_vprintf_other(format, ap);
format++;
ret += ft_vprintf_other(fmt, ap);
fmt++;
}
return (ret);
}