Hi! I was also looking for the same. I tried it out myself.
Please take a look at this & try it out.
Is this correct as per your requirements? I feel you may wana debug it for the logic. but the code is self explanatory.
Before the function ends, someone would wana add a reverse string revstr that counts the array. Im not good with pointers as such but the intention of pointer should be clear. Similarly, during rev str the pointer would keep decrementing & print the values from char arrays.
Do reply & let me know if it worked out!
Thanks.
Code:
 
char hex_ret(int X)
{
 int quotient;
 int rem;
 char i[16]; void *p=i;
 char r[]={'A','B','C','D','E','F','/0'};
 
   if (X>=16)
   {
    quotient=X/16;
    rem=X%16;
    if (quotient>=16)
    {
     if (rem>9)
     {
      int finalchar=rem-9;
      *p=r[finalchar-1];
      p++;
      hex_ret(quotient);
     }  
     else
     {
      *p=rem;
      p++;
      hex_ret(quotient);
     }  
    } 
    else
    {
     if (quotient>9 && quotient<=15)
     {
      *p=rem;
      p++;
      int finalchar=quotient-9;
      *p=r[finalchar-1];
      *p++='/0';
     }
     else
     {
      *p=rem;
      p++;
      *p=qoutient;
      *p++='/0';
     }
 
    }
   } 
   else
   {
    int finalchar=quotient-9;
    *p=r[finalchar-1];
   }  
}
Attached Files
File Type: txt int2hex.txt (795 Bytes, 0 views)

Last edited by shabbir; 30Dec2012 at 09:12.. Reason: Code blocks