Code:
typedef struct
{
unsigned char
b0:1,b1:1,b2:1,b3:1,b4:1,b5:1,b6:1,b7:1;
}
bitset;
So I got a struct consisting of a char with 8x1bit identifiers.
For example I'll make 50 of them.
Code:
bitset* collection = calloc(50, 1);
Now giving each char binary data.
Code:
for (i = 0; i < 50; i++)
{
collection[i].b0 = 1; collection[i].b1 = 0;
collection[i].b2 = 0; collection[i].b3 = 1;
collection[i].b4 = 1; collection[i].b5 = 0;
collection[i].b6 = 1; collection[i].b7 = 1;
}
The values aren't irrelevant, I just want to know if there's a way of looping through the bits to manipulate them. Here's a concept snippet:
Code:
for (i = 0; i < 50; i++)
{
for (j = 0; j < 8; j++)
{
collection[i].j = 1;
}
}
That's obviously not the way to go but do you think it involves naming the identifiers something else?
Please enlighten me fellow programmers