summaryrefslogtreecommitdiff
path: root/ft_puthexupper.c
diff options
context:
space:
mode:
authoryctct <yctct>2026-01-28 12:43:28 +0100
committeryctct <yctct>2026-01-28 12:43:28 +0100
commit925989f7e7af67d965e2b501a51068acfe449ab0 (patch)
tree7a83e51d2872f9c97abf3166f883ff8dfcf7e2e0 /ft_puthexupper.c
Add all files, first commit
Diffstat (limited to 'ft_puthexupper.c')
-rw-r--r--ft_puthexupper.c26
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);
+}