Skip to content

Commit

Permalink
write numbers in hexadecimal upper %X (base 16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Walid Araissi committed Nov 10, 2022
1 parent 108e39c commit 3d454a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ft_putnbr_base_upper.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
/* By: waraissi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/09 18:43:07 by waraissi #+# #+# */
/* Updated: 2022/11/09 20:16:28 by waraissi ### ########.fr */
/* Updated: 2022/11/10 18:10:06 by waraissi ### ########.fr */
/* */
/* ************************************************************************** */

#include "ft_printf.h"

void ft_putnbr_base_upper(unsigned int nbr, int *res)
void ft_putnbr_base_upper(unsigned int nbr, int *res)
{
char base[] = "0123456789ABCDEF";
char *base;

base = "0123456789ABCDEF";
if (nbr < 16)
ft_putchar(base[nbr], res);
ft_putchar(base[nbr], res);
else
{
ft_putnbr_base_upper(nbr / 16, res );
ft_putnbr_base_upper(nbr / 16, res);
ft_putnbr_base_upper(nbr % 16, res);
}
}
}

0 comments on commit 3d454a7

Please sign in to comment.