Have a look at this:
import streams
type
MyType* = object
somefield*: array[10, int16]
var t1, t2: MyType
t1.somefield[0] = 1
t2.somefield[0] = 2
var f = newFileStream("/tmp/tmp.mytype", fmWrite)
if not f.isNil:
f.write t1
f.write t2
f.flush
var r1, r2: MyType
var f2 = newFileStream("/tmp/tmp.mytype", fmRead)
discard f2.readData(r1.addr, r1.sizeof)
discard f2.readData(r2.addr, r2.sizeof)
echo r1.somefield
echo r2.somefield
- how to read/write object from/to binary file? luntik2012
- Re: how to read/write object from/to binary file? luntik2012
- Re: how to read/write object from/to binary file? luntik2012
- Re: how to read/write object from/to binary file? c0ntribut0r
