Hexadecimal data

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);
fcogilgoAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
RONSLOWConnect With a Mentor Commented:
dec2hexa is just the standard itoa function, with a radix of 16

hexa2deb is just strtol with a base of 16.
0
 
RONSLOWCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.