Skip to content

Instantly share code, notes, and snippets.

@ker2x
Created July 22, 2016 09:22
Show Gist options
  • Save ker2x/3ba9dcaa80782bcb59e68c6944a39273 to your computer and use it in GitHub Desktop.
Save ker2x/3ba9dcaa80782bcb59e68c6944a39273 to your computer and use it in GitHub Desktop.
unsigned int
chars_to_int(char * from, int start, int end) {
/* better way : byte copy */
unsigned int value = 0;
unsigned char buf;
int exp;
int pos=start;
for( ; pos <= end ; pos ++ ) {
exp = (end - pos);
buf = from[pos];
value += buf * (1 << (8*exp)) ;
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment