I've used various data handling schemes based on random access files in the past before databases were prevalent. For instance with small files I used a index/data file pattern. This consisted of two files. One is the data file and holds a number of records that can vary in length. The other file is an index file and has the same number of records as the data file. In the index file though each record is the same length and consists of two parts which fit into a struct.
struct {
fpos_t pos;
int size;
} indexrec;
The type fpos_t is implementation defined and used in fsetpos() and fgetpos(). These are the more modern versions of fseek and ftell and are most useful for creating bookmarks. If you are calculating a file position and need to set it then you should use fseek() and likewise ftell() to give you the int current position.
In reality fpos_t is probably just an int but you should use type fpos_t for portability. It holds a copy of the current file pointer. This is a property of a random access file that says where the next read or write takes place and is zero based. It has a granularity of 1 so you can position it any any point in the file.
On the next page : An Example of Random Access Strings

