From 5b4b292a5353586f98bd1cc882e22008457d56f6 Mon Sep 17 00:00:00 2001 From: Xamora Date: Mon, 21 Nov 2022 18:33:39 +0100 Subject: [PATCH] Correction 'p' et la fonction get_size --- ft_get_size.c | 5 +++-- ft_putvd.c | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ft_get_size.c b/ft_get_size.c index 4916c4f..cdc97bb 100644 --- a/ft_get_size.c +++ b/ft_get_size.c @@ -12,14 +12,15 @@ #include "ft_printf.h" -int ft_get_size(long n) +int ft_get_size(long long n) { long i; if (n == 0) return (1); i = 0; - n *= (n > 0) - (n < 0); + if (n < 0) + n = n * -1; while (n > 0) { i++; diff --git a/ft_putvd.c b/ft_putvd.c index 30be7cb..f795732 100644 --- a/ft_putvd.c +++ b/ft_putvd.c @@ -16,19 +16,22 @@ static int ft_putnbrhexull(unsigned long v) { int tmp; int count; + char hex[100]; count = 0; tmp = 0; - while (v > 0) + while (v != 0) { tmp = v % 16; if (tmp < 10) - ft_putchar(tmp + 48); + hex[count++] = tmp + 48; else - ft_putchar(tmp + 87); + hex[count++] = tmp + 87; v = v / 16; - count++; } + tmp = count - 1; + while (tmp >= 0) + ft_putchar(hex[tmp--]); return (count); }