Hello.
I don't know how to serialize (in binary mode) a struct with dynamic memory by the method ofstream/ifstream, I was searching in the net, but I can't find it.
How could I?
P. S.: Sorry for my bad English.
I'm not quite sure what you are looking for, but if I understand you correctly, you may want to look at this: http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/
If you want to view data one bit at a time, you can just use a data mask, or a logical AND. That will 'select' the bits that you want to view. Then if the result is zero, the 'selected' bit(s) are off. Otherwise, they are on. If my memory serves me right, the operator for bitwise and is &
1 2 3 4 5
int a;
if (a & 128 != 0) //Check status of bit 7
cout<<1;//Bit 7 is high
else
cout<<0;//Bit 7 is low
Well, you must know the size of the arrays, so you should accompany the pointers with size_t variables that save the array item count. After you do that, you serialize by writing (<<) the array item count first, then each individual item. When you deserialize, you read (>>) the array item count, then allocate the memory, then read each individual item.
Simple, you never initialize the MyInt array when reading from the file. Didn't you notice? You must initialize myStruct.MyInt with a size of myStruct.MyIntSize.