Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenni-Foued committed Oct 27, 2020
1 parent 5430f87 commit 3dedb05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions _printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int (*printer(char formati))(va_list)
int _printf(const char *format, ...)
{
va_list arg;
int i = 0, print_counter = 0;
int i = 0, p_counter = 0;
int (*f)(va_list);

if (!format || (format[0] == '%' && format[1] == '\0'))
Expand All @@ -48,29 +48,29 @@ int _printf(const char *format, ...)
{
_putchar(format[i]);
i++;
print_counter++;
p_counter++;
}
else
{
f = printer(format[i + 1]);
if (f != NULL)
{
print_counter = f(arg);
p_counter = f(arg);
i++;
}
}
if (f == NULL)
{
_putchar(format[i]);
print_counter++;
p_counter++;
}
}
else
{
_putchar(format[i]);
print_counter++;
p_counter++;
}
}
va_end(arg);
return (print_counter);
return (p_counter);
}
5 changes: 3 additions & 2 deletions print_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ int print_i(va_list arg)
{
ar2 /= 10;
}
i--;
for (j = 1; i; i--)
j * 10;
j *= 10;
for (i = 0; ar; i++)
{
_putchar((ar / j) + '0');
_putchar(((ar / j) %10) + '0');
count++;
ar %= j;
j /= 10;
Expand Down

0 comments on commit 3dedb05

Please sign in to comment.