Skip to content

Commit

Permalink
fix for double %
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenni-Foued committed Oct 27, 2020
1 parent b0c4555 commit 5916aaa
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions _printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ int _printf(const char *format, ...)
{
if (format[i] == '%')
{
if (format[i + 1] == '%' || format[i + 1] == '\0')
if (format[i + 1] == '%')
{
_putchar(format[i]);
i++;
p_counter++;
}
else if (format[i + 1] == '\0')
{
_putchar(format[i]);
p_counter++;
return (p_counter);
}

else
{
f = printer(format[i + 1]);
Expand All @@ -58,11 +65,11 @@ int _printf(const char *format, ...)
p_counter = f(arg);
i++;
}
}
if (f == NULL)
{
else
{
_putchar(format[i]);
p_counter++;
}
}
}
else
Expand Down

0 comments on commit 5916aaa

Please sign in to comment.