How to copy Bitset to char array in C++

Hi,
I am new to C++ and STL, especially Bitset.
I need o solve the following:


char * MyBuffer;
MyBuffer = (char *) malloc( sizeof(char) * (64 * 256));

bitset<16384> MyBitSet;

MyBitSet[0] = true;
MyBitSet[16383] = false;

Question:
How do I copy the whole MyBitSet to MyBuffer?
Does "MyBuffer << MyBitSet" work?

Thanks,
Hy Phan
You can use MyBitset.toulong() to get an unsigned long, then put the four byes into MyBuffer. You'd have to loop this ;)
Thanks..But I don't understand...:=((

I thought MyBitSet.toulong() returns to unsigned long from the whole MyBitSet.
Please note that the size of MyBitSet is 2048 bytes.

Could you be kind to show me how to loop it?

Thanks,
HP
Thanks..But I don't understand...:=((

I thought MyBitSet.toulong() returns to unsigned long from the whole MyBitSet.
Please note that the size of MyBitSet is 2048 bytes.

Could you be kind to show me how to loop it?

Thanks,
HP
Well, you would take 16 bits at a time and put them in a temporary bitset and .toulong() from that. ;)
Topic archived. No new replies allowed.