嗨!
请问如果我想从FILE(.dat)里删除一些记录,请问要如何写呢?
void record::DeleteRecord() //Prototype function to delete record
{
int found=0;
char member[10];
record rec;
fstream file;
clrscr();
file.open("Members.dat",ios::in); //To get data from file
gotoxy(23,5);
cout<<" Database ";
gotoxy(13,6);
cout<<"-----------------------------------------------------";
gotoxy(13, 17);
cout<<"-----------------------------------------------------";
gotoxy(25,7);
cout<<"Enter member's first name: ";
cin>>member;
file.read((char*)&rec,sizeof(rec));
while(!file.eof() && found==0)
{
if(stricmp(member,rec.firstname)==0)
{
// rec.DisplayInput();
Extra(); //这里作删除,请问要怎么写呢?
gotoxy(32,11);
cout<<"Record deleted!";
found=1;
gotoxy(23,18);
cout<<"Press any key to return to main menu";
getch();
clrscr();
}
file.read((char*)&rec,sizeof(rec)); //To get data from file
}
if(found==0)
{
gotoxy(32,11);
cout<<"Records not found!";
gotoxy(23,18);
cout<<"Press any key to return to main menu";
getch();
clrscr();
}
}
--------------------next---------------------
阅读(1155) | 评论(0) | 转发(0) |