Solved

Convert hexadecimal to decimal

Posted on 2002-04-19
2
1,320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

752 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