JOE_WIEMANN
asked on
Hexadecimal Strings
How do I convert from a hexadecimal string to an integer??? I am using the g++ compiler under unix.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or, use 'strtol()':
#include <stdlib.h>
char* pcHex ="0xff";
char* pcCnvEnd;
int n;
n = (int) strtol ( pszHex, &pcCnvEnd, 16); // <-- numeric base!!
Feel free to ask if you need more information!
#include <stdlib.h>
char* pcHex ="0xff";
char* pcCnvEnd;
int n;
n = (int) strtol ( pszHex, &pcCnvEnd, 16); // <-- numeric base!!
Feel free to ask if you need more information!
ASKER
Thanks alot -- works wonders
ASKER
F = 15
E = 14
D = 13
C = 12
B = 11
A = 10
9 = 9
8 = 8
7 = 7
6 = 6
5 = 5
4 = 4
3 = 3
2 = 2
1 = 1
0 = 0