I have a function that returns a bool (8 times) in a loop, I want to construct an uint8_t, as you probably guessed I'm new to C and C++.
unsigned int data[8];
for(int i = 0; i < 8; i++) {
// 1 or 0 if switch is on or off
int value = (int)functionThatReturnsBool(i);
data[i] = value;
}
// Needs B00000000 (with the correct switches on)
functionThatNeeds(uint8_t ???);
It's not completely clear what you're trying to do here, but if you're trying to pack 8
bool
s into oneuint_8
, something like this should trivially do it: