Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2349811
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:07:43

嗨!
请问如果我想从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) |
给主人留下些什么吧!~~