I don't think it'd work with an array, because if you have an array of 6-bit ints, the compiler would have to do a LOT of work to find the actual section of memory you're referring to when you use the subscript operator.
>>But ive used binary representations to check and infact have seen that the bits are placed in the order of the variables from top to bottom in the struct
Right, and there's no problem with this observation; however, what I'm saying is that just because "it works on my machine" doesn't mean it works on every machine - or more specifically, every compiler. What I meant was, 'top to bottom in the struct' may have no meaning. As for the blowfish algorithm, what you're seeing is just one implementation of the algorithm; it may simply be wrong. On the other hand, I could also be totally wrong and just confusing you I'll see if I can check up on this.
**EDIT**
OK, well I can't find anything about variable arrangement anywhere at all (actually, I don't know what to search for). I remember, though, that you cannot directly copy the binary representation of one struct over top of another 'equivalent' struct.
Code:
struct A
{
int a;
int b;
}a;
struct B
{
int a;
int b;
}b;
memcpy(&a, &b, sizeof(a)); //Bad, structs are not equivalent
Perhaps the problem with this has to do with struct packing problems as opposed to arrangement. However, this also brings up the problem:
Code:
struct Bits
{
int a : 1;
int b : 1;
int c : 1;
int d : 1;
int e : 1;
int f : 1;
int g : 1;
int h : 1;
};
union UCharBits
{
unsigned char uchartype;
Bits bitstype; //What size is the structure Bits?
};
What if Bits is padded to 4 bytes, and the padding bits go on the wrong end of the struct? The bits you access then will be meaningless. I'm not sure if this is possible either, but if not, then I can't think of any reason why the earlier (guaranteed bad) example is harmful.