Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
JennyHadir committed Oct 30, 2020
1 parent 638866e commit 886220f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions _printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int (*printer(char formati))(va_list)
{'r', print_r},
{'S', print_S},
{'p', print_p},
{'u', print_u},
{'\0', NULL}
};
int i = 0;
Expand Down
1 change: 1 addition & 0 deletions holberton.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ int print_b(va_list arg);
int print_r(va_list arg);
int print_S(va_list arg);
int print_p(va_list arg);
int print_u(va_list arg);
#endif
35 changes: 35 additions & 0 deletions print_u.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "holberton.h"
/**
* print_u - prints unsigned integer function
*@arg: integer to print
* Return: number of integer printed
*/
int print_u(va_list arg)
{
unsigned int ar = va_arg(arg, int);
unsigned int count = 0, i = 0, ar2 = 0, j = 1;
if (ar > 9)
{
ar2 = ar;
for (; ar2; i++)
{
ar2 /= 10;
}
i--;
for (j = 1; i; i--)
j *= 10;
for (i = 0; ar; i++)
{
_putchar(((ar / j) % 10) + '0');
count++;
ar %= j;
j /= 10;
}
}
else
{
_putchar(ar + '0');
count++;
}
return (count);
}

0 comments on commit 886220f

Please sign in to comment.