• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

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);
0
fcogilgo
Asked:
fcogilgo
  • 2
1 Solution
 
RONSLOWCommented:
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

Featured Post

Technology Partners: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now