#include <stdlib.h>
#include <fstream.h>
#include "auto.h"

const char* file_name = "auto.dat";

ofstream& operator << (ofstream& fout, automobile& Ob)
{
   fout.write((char*)& Ob, sizeof(automobile));
   return fout;
}

void main()
{
   int i = 0, n;
   automobile A;

   ofstream fio(file_name, ios::binary|ios::in|ios::out|ios::app);
   if (!fio) { cout << "ERROR !"; exit(1); }

	fio.seekp(0,ios::end);
	long size = fio.tellp()/sizeof(automobile);
	cout << "File contain " << size << " objects\n";

   cout << "How many objects you wanna add ?  ";
   cin >> n;
   while(i < n) {
	 cin >> A;
	 fio << A;
	 i++;
   }

	fio.seekp(0,ios::end);
	size = fio.tellp()/sizeof(automobile);
	cout << "Now file contain " << size << " objects\n";
	fio.close();
}