int number = strtol(str, NULL, 16); // The "16" means hexadecimalFull Example:
#include <stdio.h> #include <stdlib.h> // for strtol() int main() { int number = strtol("FF", NULL, 16); // The "16" means hexadecimal printf("number=%d decimal\n", number); printf("number=%x hex\n", number); }Output:
number=255 decimal number=ff hex