How to create a byte out of 8 bool values (and vice versa)?
The hard way: unsigned char ToByte(bool b[8]) { unsigned char c = 0; for (int i=0; i < 8; ++i) if (b[i]) c |= 1 << i; return c; } And: void FromByte(unsigned char c, bool b[8]) { for (int i=0; i < 8; ++i) b[i] = (c & (1<<i)) != 0; } Or the … Read more