Solved

Hexadecimal data

Posted on 2000-04-06
2
430 Views
Last Modified: 2008-03-10
Hallo,

I need a function that makes the convertion hexadecimal<-->decimal.
The hexadecimal value is a CString, and the decimal value is an integer.

Something like:

int hexa2dec (CString input);

CString dec2hexa (int input);
0
Comment
Question by:fcogilgo
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 2689875
dec2hexa is just the standard itoa function, with a radix of 16

hexa2deb is just strtol with a base of 16.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2689889
int hexa2dec (CString input) {
  char* dummy;
  return strtol(input,&dummy,16);
}
CString dec2hexa (int input) {
  CString string;
  itoa(input,string.GetBuffer(64),16);
  string.ReleaseBuffer();
  return string;
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now