123456789
bool get_bit( unsigned char* bits, unsigned bytes, unsigned bit ) // Takes an array of byte-packed 'bits' // of length 'bytes' bytes, and returns the indexed 'bit'. { unsigned byte_index = bit / 8; unsigned bit_index = bit % 8; unsigned mask = 1 << bit; return (bits[ byte_index ] & mask) != 0; }