I have a string like this:
\"00c4\"
And I need to convert it to the numeric value that would be expressed by the literal:
0
int val_from_hex(char *hex_string) { char *c = hex_string; int val = 0; while(*c) { val <<= 4; if(*c >= '0' && *c <= '9') val += *c - '0'; else if(*c >= 'a' && *c <= 'f') val += *c - 'a' + 10; c++; } return val; }