atoi() from hex representation string

vico picture vico · Dec 18, 2013 · Viewed 73.1k times · Source

Need to make int from hex representation string like "0xFA" or better "FA". Need something like atoi("FA"). Is there are any standard solutions for that?

Answer

V-X picture V-X · Dec 18, 2013

Try to use strtol():

strtol("FA", NULL, 16);