minus and 0 flags WIP

This commit is contained in:
David Gailleton
2025-11-19 21:02:04 +01:00
parent 66878549eb
commit bd1c66d86f
15 changed files with 317 additions and 57 deletions

View File

@@ -6,19 +6,31 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/17 12:06:35 by dgaillet #+# #+# */
/* Updated: 2025/11/19 13:35:40 by dgaillet ### ########lyon.fr */
/* Updated: 2025/11/19 20:14:08 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "ft_printf_bonus.h"
#include <unistd.h>
int print_hex(unsigned long long nbr, int upper)
int print_hex(t_arg *arg, unsigned long long nbr)
{
int count;
count = 0;
if (nbr == 0)
return (write(1, "0", 1));
if (upper)
return (ft_putnbr_base(nbr, "0123456789ABCDEF", 16));
count += write(1, "0", 1);
else
return (ft_putnbr_base(nbr, "0123456789abcdef", 16));
{
if (arg->hash && arg->arg == 'X')
count += write(1, "0X", 2);
else if (arg->hash)
count += write(1, "0x", 2);
count += print_chars(arg->zero - count - nbr_size_base(nbr, 16), '0');
if (arg->arg == 'X')
count += ft_putnbr_base(nbr, "0123456789ABCDEF", 16);
else
count += ft_putnbr_base(nbr, "0123456789abcdef", 16);
}
return (count);
}