|
From: graeme <gr...@dr...> - 2001-09-18 08:05:23
|
I'm not quite sure what it is you intend to do, so maybe you could clarify
your request.
1) Are the variables to be created before you compile (relatively simple) or
dynamically (a little harder)?
2) Will all the record fit into a single file or different files (if
different how will they be split - by record or by field?)
In the first approach to question 1) you will just need to create a
structure or class to hold the variables. They have already been designed so
the structure should be easy to create:
For example:
struct addr
{
char name [30];
char street [40];
char city [20];
char province [3];
unsigned long int code;
};
The dynamic approach requires a little more work. First you need to know how
much memory each record will require and then allocate sufficient space for
that record. You will probably want to use the sizeof(int) and sizeof(char)
function calls to ensure that the size allocation is portable. Once you have
determined the total size requirements the value can be stored in the memory
space by using pointer arithmetic and union overlays. This gets a little
complicated so I won't go into the detail unless you need it.
With the saving to disk there are many approaches and I think that the
approach you take will depend upon whether you are using C or C++. I tend to
use C++ and have a preference for the << operator which I make a friend of
the class I am creating.
>I am trying to create a "datatable" (similar to a database about 10 =
>records containing about 26 variables per record), the "datatable" will =
>contain integer and text values. And I need to find out how to create =
>the storage areas and how to save them to a discfile and load them back =
>in to memory.
|