Hello
I have a string parser who receives as its input a hex number:
For Example:
String X=”0x120005f38″
As you can see the number is in HEX, how do I convert this to unsigned long?
If this was decimal based string I could use the string to unsigned long function.
I am guessing there are a couple of steps, and I am not sure what order or functions to use.
1)Where I need to convert Hex into decimal
2)and String into unsigned long.
This seems very tricky to me, any ideas?
Use
strtoul:strtoulreference on cplusplus.com. See how that works on Codepad.EDIT: Changed to
strtoul, did not notice thatunsigned longis required.