/*Can anybody help me .... there is a problem when i read from file in an array of objects ..
the error states that :

Debug assertion failed !
file : dbgheap.c
line :1017

Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

if i ask OS to ignore error it states another error i.e.
Debug Error !
DAMAGE : before (null) block at 0x01308910
*/

fstream out_air("air.txt", ios ::out | ios ::binary | ios ::in);
	if(!out_air)
	{
		cout<<"\nerror"<<endl;
		exit(1);

	}
	out_air.seekp(0);
	for(i=0;i<30;i++)
	out_air.write((const char*)&plane[i]),sizeof(CAircraft));
	cout<<"\nfile written"<<endl;
	out_air.clear();
//	out_air.close();
	system("pause");
	out_air.seekg(0);

	CAircraft me[30];
//	ifstream in_air("air.txt",ios:: in | ios ::binary);
	for(i=0;i<30;i++)
		out_air.read((char *)(&me[i]),sizeof(CAircraft));
        out_air.clear();
	out_air.close();

//now as main ends there occurs the error i.e. when the destructor //of fstream is called the error generates

is plane a dynamically created array or just an array of objects?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.