Solved

Convert hexadecimal to decimal

Posted on 2002-04-19
2
1,319 Views
Last Modified: 2008-01-09
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
Comment
Question by:czz
2 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 50 total points
ID: 6955330
Is strtol what you are looking for?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6957453
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question