1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| #include "main.h"
/**
* decint_print - prints a decimal and integer
* @list: decimal argument
* Return: counter
*/
int decint_print(va_list list)
{
unsigned int absolute, aux, countnum, count;
int n;
count = 0;
n = va_arg(list, int);
if (n < 0)
{
absolute = (n * -1);
count += _putchar('-');
}
else
absolute = n;
aux = absolute;
countnum = 1;
while (aux > 9)
{
aux /= 10;
countnum *= 10;
}
while (countnum >= 1)
{
/*increment digit count*/
count += _putchar(((absolute / countnum) % 10) + '0');
countnum /= 10;
}
return (count); |
Partager