So I converting a decimal value into hex, but I need to print it out from an array. I'm not sure where to go from here.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int hexa = 16, deci, quotient, p;
void dec2hex(unsigned int x, char hex[])
{
for (p = 1; p<=x; p++)
quotient = x / hexa;
hex[32] = 0;
}
if (op == 'h')
{
dec2hex(dec, hex);
printf("%s\n", hex);
getche();
}
I left some parts out of course but I just need help with the hex section of my code. When I run it the binary section works just fine but hex prints out an empty array. Any help would be greatly appreciated.