typedef unsigned long ADDRESS;
struct atom
{int op;
ADDRESS left;
ADDRESS right;
ADDRESS result;
int cmp;
int dest;
};
FILE * atom_file_ptr;
atom_file_ptr = fopen ("atoms", "wb");
atom (int operation, ADDRESS operand1, ADDRESS operand2,
ADDRESS result, int comparison, int dest)
{
struct atom outp;
outp.op = operation;
outp.left = operand1;
outp.right = operand2;
outp.result = result;
outp.cmp = comparison;
outp.dest = dest;
fwrite (&outp, sizeof (struct atom), 1, atom_file_ptr);
}
fclose (atom_file_ptr);
struct atom inp;
atom_file_ptr = fopen ("atoms","rb");
while ( fread (&inp, sizeof (struct atom), 1, atom_file_ptr) )
{
...
}
fclose (atom_file_ptr);