"Angus McLeod" <angus.mcleod@VERT/ANJO> wrote in message news:
4510AF1E.2178.dove-prg@anjo.com...
Here's the bugger - I can output the strings easily. When I want to
reinput and rebuild this structure on later executions, how should I go about it?
Look at fscanf() or consider writing a fixed-length record for each
struct.
I have since had a few lectures on writing dynamic structures to disk. A fixed length record is just too undesirable in this situation because the record size is above a normal disk cluster size. The strategy I've learned
is to put a flag byte in that will trigger the end of a flag and to just
suck up the processing time. This works relatively fast if you can put your byte flag on a word boundary, so eg on a 32 bit machine with a structure of say :
8 characters (8 bytes)
3 integers (12 bytes)
{ok to put byte if this is it, same word is guarenteed as long as you're not allocating memory from an arena, eg you use new or malloc etc)
The boner is you read it byte by byte from a buffer to prevent excessive
disk access.
If you're in allocation from arena I don' t know how this might work well.
---
þ Synchronet þ [aceshigh.dyn.dhs.org] - Come fly our friendly skies!