I would not store the bits in an array - I would use them with char.
So, you start with the value char 0: char bit = 0;
When you get the first bit, OR with what you have: bit |= bit_just_read;
Continue to do this with each bit, moving accordingly; those. after you get the next bit, do bit |= (next_bit << 1); . Etc.
After you read your 8 bits, bit will be the appropriate ASCII value, and you can print it or do whatever you want to do with it.
source share