A bit of binary I/O

Frank Benoit (keinfarbton) benoit at tionex.removethispart.de
Sat Jan 20 15:09:34 PST 2007


> // 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 );



More information about the Digitalmars-d-learn mailing list