• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1325
  • Last Modified:

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?
0
czz
Asked:
czz
1 Solution
 
GGRUNDYCommented:
Is strtol what you are looking for?
0
 
DanRollinsCommented:
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now