A bit of binary I/O

Heinz billgates at microsoft.com
Sat Jan 20 15:46:26 PST 2007


Frank Benoit (keinfarbton) Wrote:

> > // Primitive
> > 09 00 00 00 00 00 00 00 0B 00 00 00 A0 C7 41 00
> 
> 09 00 00 00 00 00 00 00 // the ulong with value 9
> 0B 00 00 00             // arraysize 11
> A0 C7 41 00             // pointervalue to the start of data
> 
> > // Structure
> > 09 00 00 00 00 00 00 00 0B 00 00 00 A0 C7 41 00
> 
> same here
> 
> > // Class
> > C0 3F 91 00
> 
> the first 4 bytes of your class. mtt.sizeof is the size of the reference
> not the size of the object itself.
> 
> s.ptr is the pointer to the array data.
> &s is the address of the struct, that holds the array length and the
> pointer to the data.
> To write the string, you might want to try this:
> 	myFile.writeExact( s.ptr, s.length );
> 

I get it, but if i'm actually writing the address of my data and not the data itself then why i'm able to retrieve the data even if it's not there? 


More information about the Digitalmars-d-learn mailing list