Skip to content

Instantly share code, notes, and snippets.

@raholland79
Created April 19, 2011 01:37
Show Gist options
  • Save raholland79/926639 to your computer and use it in GitHub Desktop.
Save raholland79/926639 to your computer and use it in GitHub Desktop.
c
while (acc < UINT_MAX / 16) {
if ( s[i] >= '0' && s[i] <= '9' ) {
acc *= 16;
acc += s[i] - '0';
} else if (s[i] >= 'A' && s[i] <= 'F') {
acc *= 16;
acc += s[i] - 'A' + 10;
} else if (s[i] >= 'a' && s[i] <= 'f') {
acc *= 16;
acc += s[i] - 'a' + 10;
} else {
putchar('\n');
return acc; /* end */
}
putchar(s[i]);
++i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment