Number is a string == "0x1388" which is 5000 in dec. I'm not sure how to convert this hex string into the int value == 0x1388; Any help? And thanks in advance.
value = strtol (number.c_str(),NULL, number.size());
Number is a string == "0x1388" which is 5000 in dec. I'm not sure how to convert this hex string into the int value == 0x1388; Any help? And thanks in advance.
value = strtol (number.c_str(),NULL, number.size());
The third argument is the base of the number you want to convert. In your case, the number is base 16 (hexadecimal), so you should pass 16
as the third argument. You can also pass 0
, which will let the function determine the base from the prefix 0x
.
Fix 3rd argument
value = strtol (number.c_str(),NULL, 16);
^^ Base of hexadecimal number