本文介绍了为什么我的Delete()函数不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

下面的代码









Code below









void Staff::Delete() {
	char tgtIC[15];
	Staff objStaff;
	fstream iofile( "Employee.dat",ios::in || ios::out);
	if (!iofile) 				// overloaded ! operator 
	{ 														// or: if( outClientFile.fail() ) 
		cerr << "\t File could not be opened" << endl;
		system( "PAUSE" );
		exit( 1 ); 					// prototype in cstdlib 
	}
	fflush(stdin);				// To remove any previous content stored in memory
	cout<<endl;
	cout<< "\t =================================================="
	cout<< "\t < DELETE A RECORD >" <<endl;
	cout<< "\t Enter IC that you want to delete : "
	cout<< "\t ==================================================" <<endl;

	cout<< "\t |      Enter Staff IC : " ;
	cin.getline(tgtIC, 15);
//==================================================" <<endl;

	iofile.read((char *) (&objStaff), sizeof(Staff));
	while (!iofile.eof())
	{	//cout<< "t :" <<tgtIC<< "obj : " <<objStaff.IC<<endl;
		if (!strcmp(tgtIC,objStaff.IC)==0)
			display(objStaff);
		else
			cout<< "\t Delete record - by writing a blank record if using random file" <<endl;
		iofile.read((char *) (&objStaff), sizeof(Staff));
	}
	iofile.close(); // explicit closing 
}

推荐答案




这篇关于为什么我的Delete()函数不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 07:44