Skip to content

Instantly share code, notes, and snippets.

@Sascha-T
Created September 8, 2020 21:23
Show Gist options
  • Save Sascha-T/e50ae994375c8241b215c27b7f24f9eb to your computer and use it in GitHub Desktop.
Save Sascha-T/e50ae994375c8241b215c27b7f24f9eb to your computer and use it in GitHub Desktop.
hex to int :D
int stli(char *c) {
int ret = 0;
while (*c != 0) {
ret = ret << 4;
if(*c >= '1' && *c <= '9') {
ret += *c - 48;
}
if(*c >= 'a' && *c <= 'f') {
ret += *c - 87;
}
c++;
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment