Note that the above sample code works only for upper case hex. Not a big deal. Just add another else if:
else if (c >= 'a' && c <= 'f') {
x *= 16;
x += (c - 'a') + 10;
}
Note that the above sample code works only for upper case hex. Not a big deal. Just add another else if:
else if (c >= 'a' && c <= 'f') {
x *= 16;
x += (c - 'a') + 10;
}