0

I am reading hex value from strings like

char *str = "0xF";

Now I want to store this value in an int type to pass that int variable in the function. What would be the correct method to do it?

*Edit*I dont want to convert this from hex to decimal but the function requires value in form of hex only. So i want to change this char* into int.

lokesharo
  • 305
  • 2
  • 11
  • 1
    This has been [asked and answered before](http://stackoverflow.com/questions/10156409/convert-hex-string-char-to-int) =) – Tomas Aschan Mar 27 '14 at 07:51

1 Answers1

0

you can use strtol function with the base as 16 to convert from hexadecimal string to integer. read this to know about strtol

LearningC
  • 3,182
  • 1
  • 12
  • 19