feat: added ft_puthex
This commit is contained in:
parent
2bee25020c
commit
9bf197acbd
1 changed files with 12 additions and 0 deletions
12
srcs/ft_puthex.c
Normal file
12
srcs/ft_puthex.c
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "libft.h" // for ft_putchar
|
||||||
|
|
||||||
|
int ft_puthex(unsigned int n, int uppercase)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *digits = uppercase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||||
|
|
||||||
|
if (n >= 16)
|
||||||
|
count += ft_puthex(n / 16, uppercase);
|
||||||
|
count += ft_putchar(digits[n % 16]);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue