strtol()
If you want to use pure c++ then use stringstream c++ class.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
still use strtol()
int main()
{
char hex[]= "ABCD";
char* end = 0;
unsigned int num = strtol(hex,&end,16);
cout << num << "\n";
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I originally tried the stringstream thing similar to what you posted but it wouldn't work for me -- just proeuced some gigantic number. After a little more testing I find that the problem was becuse of my use of hex[].
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343