Correction 'p' et la fonction get_size

This commit is contained in:
Xamora 2022-11-21 18:33:39 +01:00
parent c70b29dfd1
commit 5b4b292a53
2 changed files with 10 additions and 6 deletions

View file

@ -12,14 +12,15 @@
#include "ft_printf.h" #include "ft_printf.h"
int ft_get_size(long n) int ft_get_size(long long n)
{ {
long i; long i;
if (n == 0) if (n == 0)
return (1); return (1);
i = 0; i = 0;
n *= (n > 0) - (n < 0); if (n < 0)
n = n * -1;
while (n > 0) while (n > 0)
{ {
i++; i++;

View file

@ -16,19 +16,22 @@ static int ft_putnbrhexull(unsigned long v)
{ {
int tmp; int tmp;
int count; int count;
char hex[100];
count = 0; count = 0;
tmp = 0; tmp = 0;
while (v > 0) while (v != 0)
{ {
tmp = v % 16; tmp = v % 16;
if (tmp < 10) if (tmp < 10)
ft_putchar(tmp + 48); hex[count++] = tmp + 48;
else else
ft_putchar(tmp + 87); hex[count++] = tmp + 87;
v = v / 16; v = v / 16;
count++;
} }
tmp = count - 1;
while (tmp >= 0)
ft_putchar(hex[tmp--]);
return (count); return (count);
} }