Skip to content

Instantly share code, notes, and snippets.

@mysteriouspants
Created February 16, 2012 17:28
Show Gist options
  • Save mysteriouspants/1846606 to your computer and use it in GitHub Desktop.
Save mysteriouspants/1846606 to your computer and use it in GitHub Desktop.
Why parse hex when you don't have to?
#include <stdio.h>
int main(int argc, char *argv[]) {
const char* c = "1A FF";
int a, b;
sscanf(c, "%2x %2x", &a, &b);
printf("a: %3d b: %3d\n", a, b);
printf("a: %3x b: %3x\n", a, b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment