Skip to content

Instantly share code, notes, and snippets.

@parth-paradkar
Created February 20, 2021 14:16
Show Gist options
  • Select an option

  • Save parth-paradkar/a43add692bcdd3b869650f15a0633c35 to your computer and use it in GitHub Desktop.

Select an option

Save parth-paradkar/a43add692bcdd3b869650f15a0633c35 to your computer and use it in GitHub Desktop.
#define byte unsigned char
void printBytes(byte *target, int size) {
byte select = 128;
byte *i = target;
while(size--) {
byte currentByte = *i;
for(int k = 0; k < 8*sizeof(byte); k++) {
printf("%d", (int)((currentByte & select) > 0));
currentByte <<= 1;
}
printf(" ");
i++;
}
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment