Link to home
Start Free TrialLog in
Avatar of czz
czz

asked on

Convert hexadecimal to decimal

Is there a function in c library to convert a hex to decimal? For example, if there is a hex number hex=01020304, how to convert it to be decimal number?
ASKER CERTIFIED SOLUTION
Avatar of GGRUNDY
GGRUNDY

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
strtol (string to long) or strtoul (string to unsigned long) will do the job, as GGrundy says.  Be sure to set the last parameter to 16 so that it will know you are converting hexidecimal digits.  For instance:

char* pEnd;
char szHexText="0102A53F";

unsigned long nBinaryValue= strtoul( szHexText, &pEnd, 16 );

-- Dan