From: billlanam AT california DOT com (Bill Lanam) Newsgroups: comp.os.msdos.djgpp Subject: Re: Storing pointers in a binary file Date: Fri, 21 Feb 1997 23:14:19 GMT Message-ID: <330e29bd.16240443@seashell.california.com> References: <19970220 DOT 152037 DOT 7567 DOT 2 DOT fwec AT juno DOT com> NNTP-Posting-Host: 140.174.210.137 Lines: 28 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On Thu, 20 Feb 1997 20:14:52 GMT, fwec AT juno DOT com (Mark T Logan) wrote: > In the vary near future I will be writing a funtion to write a set >of data to a binary file. This set of data will have pointers in >it pointing to other parts of the file. > Since the starting address of the block of data once it is loaded >into memory may change, I thought that the best way to store >this would be to subtract the starting address of the block from >each of my pointers before I store the data. Then, when I read >the file from the disk, I can add the address of whatever block >of memory I allocate to each of the pointers. > >Is this the best / easiest / most ingenius approach I can use. >If you know of any other other approaches, please help me. > There are two approachs that I thought of offhand. 1. Write the data set in a particular order without pointers to the file, read from the file in that order using your add to the data set function to recreat the original order (that requires that you can order it or that the order isn't particularly important). 2. Write the data set with either indices for pointers treating the data as an array, or with file pos. pointers, when reading from the file use random access to retrieve the data and of course use your add to the data function to recreat the original order (the pointers can be in a seperate file). Bill Lanam