   a proper bit array ?
  How can I make a struct / class for a bit array that is actually just an array of bits as opposed to BOOLs (which take up more than a bit) ?   
  I assume you don't want to use std::bitset or std::vector<bool> for some reason?The basic idea here is to use shifts, bitwise ands and bitwise ors to select individual bits within a single integer word. You'll be able to find any number of well-written tutorials and examples if you search around a bit, but here's one example anyway:typedef unsigned long word_t;enum { BITS_PER_WORD = CHAR_BIT * sizeof word_t };bool getbit(const word_t *array, size_t index) { word_t bit_mask = (word_t) 1 << (index % BITS_PER_WORD); size_t word_offset = index / BITS_PER_WORD; // is the bit set? if(array[word_offset] & bit_mask) {  return true; } else {  return false; }}void putbit(word_t *array, size_t index, bool value) { word_t bit_mask = (word_t) 1 << (index % BITS_PER_WORD); size_t word_offset = index / BITS_PER_WORD; // clear previous value array[word_offset] &= ~bit_mask; // and set the new value if(value) {  array[word_offset] |= bit_mask; }};  std::vector<bool> is a bit container, its special :)Edit: Ninja'd by such a way better post :)   ;  IIRC, std::vector<bool> is specialized to be a bit array.Edit: Damn, I'm slow tonight.   ;  It is simply not possible (assuming you are on an x86 architecture) to have data at the bit level as opposed to a multiple of the smallest datatype available such as char which I believe is always guaranteed to be 1 byte in length by specification.   ;Quote:Original post by ImtiazIt is simply not possible (assuming you are on an x86 architecture) to have data at the bit level.What? You may not be able to store bits individually, but you can certainly manipulate and pack bits.   ;Quote:Original post by Driv3MeFarQuote:Original post by ImtiazIt is simply not possible (assuming you are on an x86 architecture) to have data at the bit level.What? You may not be able to store bits individually, but you can certainly manipulate and pack bits.Yes of course, I actually edited what I wrote just to clarify. I think he wants to be able to store data on a per bit level which of course cannot be done.   ;  That depends on what you mean by "store data on a per bit level".struct BitFields {  unsigned a : 2;  unsigned b : 1;  unsigned c : 3;};;Quote:Original post by ImtiazIt is simply not possible (assuming you are on an x86 architecture) to have data at the bit level.It's more a matter of the C language not being able to expose bit indexing/pointers, really. The x86 architecture has had specialized  bit-field instruction since the 386 to do this kind of thing directly in hardware (BT, BTC, BTR, BTS.)Oh, and if you just want to pack a few flags together there's always good old C bitfields. E.g.struct flags { unsigned one : 1; unsigned two : 1; unsigned three : 1;};;  For that matter, there's nothing in the standard which demands that the processor be able to write a single char to memory without reading in the entire memory word and modifying part of it -- and some architectures can't.   