xxxxxxxxxx
// Note that u can change this function to print int values
// by changing the type and the sizeof
void print_bin(unsigned char value)
{
for (int i = sizeof(char) * 8; i != -1; i--)
printf("%d", (value & (1 << i)) >> i );
putc('\n', stdout);
}
xxxxxxxxxx
// Note that u can change this function to print int values
// by changing the type and the sizeof
void print_bin(unsigned char value)
{
for (int i = sizeof(char) * 7; i >= 0; i--)
printf("%d", (value & (1 << i)) >> i );
putc('\n', stdout);
}
xxxxxxxxxx
// Assumes little endian
void print_bin(void const * const ptr, size_t size)
{
unsigned char const *b = (unsigned char const *) ptr;
for (int i = size - 1; i >= 0; --i) {
for (int j = 7; j >= 0; --j) {
printf("%u", (b[i] >> j) & 1);
}
printf(" ");
}
puts("");
}
xxxxxxxxxx
void print_bin(unsigned char value)
{
for (int i = sizeof(char) * 7; i >= 0; i--)
printf("%d", (value & (1 << i)) >> i );
putc('\n', stdout);
}