Solved

Hexadecimal data

Posted on 2000-04-06
2
427 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

707 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

16 Experts available now in Live!

Get 1:1 Help Now