A bit of binary I/O
Heinz
billgates at microsoft.com
Sat Jan 20 15:54:54 PST 2007
Heinz Wrote:
> 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?
I think i'm getting it, the data retrieved are addresses to the start of data but in my RAM, so if i take this file to another computer the data received should be different, am i right?
To solve this and write the real data you suggest using the .ptr, is this property available in every object.
I'm sorry to bother you so much Frank: I'm interested in your oppinion about the other 2 questions.
Really thanks man, you rule.
More information about the Digitalmars-d-learn
mailing list