hi everyone,
I am trying to implement a program that converts a decimal into
Hex, I am having some problem it doesn't do the right computation, can anyone see any abnormality of my implementaion.
Here is the code:
Code:code /* this function decimal number and transforms into hex */ char HexConvert(int val) { char *iter = val+10; while(iter>=val+2){ /*compute hex digit*/ if(val) { *iter = val%16; val/=16; if(*iter<10) /*output integer*/ *iter+='0'; return iter; else /*output character*/ *iter+=55; /* ASCII Value for A (=10) is 65 (=55+10) */ return iter; } else /*fill remaining hex array with zeros*/ *iter = '0'; return iter; iter--; }