diff options
Diffstat (limited to 'ft_puthexupper.c')
| -rw-r--r-- | ft_puthexupper.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ft_puthexupper.c b/ft_puthexupper.c new file mode 100644 index 0000000..b5518bf --- /dev/null +++ b/ft_puthexupper.c @@ -0,0 +1,26 @@ + +// using unsigned int as a paramter to deal with with negative numbers +#include "ft_printf.h" + +int ft_puthexupper(unsigned int n) +{ + const char hex[16] = "0123456789ABCDEF"; + int save; + int remainder; + int counter; + + remainder = 0; + save = 0; + counter = 0; + if (n > 15) + { + save = n; + n /= 16; + remainder = save - (n * 16); + counter += ft_puthexupper(n); + counter += write(1, &hex[remainder], 1); + } + else + counter += write(1, &hex[n], 1); + return (counter); +} |
