c++中 如何对文件部分内容进行删除
展开全部
void leader::deleteform()
{
int i=0,j;
form *fp[GESHU];
ifstream fin("data.txt");
while (1)
{
if(fin.eof())break;
fp[i]=new form;
fin>>fp[i]->applier>>fp[i]->applier;
fin>>fp[i]->applicationdate>>fp[i]->applicationdate;
fin>>fp[i]->applyreason>>fp[i]->applyreason;
i++;
}
fin.close();
ofstream fout("data.txt",ios::out);
for(j=1;j<i-1;j++)
{
fout <<"申请人姓名 "<<fp[j]->applier<<"\n";
fout <<"申请日期 "<<fp[j]->applicationdate<<"\n";
fout <<"申请理由 "<<fp[j]->applyreason<<"\n";
}
fout << flush;
fout.close();
{
int i=0,j;
form *fp[GESHU];
ifstream fin("data.txt");
while (1)
{
if(fin.eof())break;
fp[i]=new form;
fin>>fp[i]->applier>>fp[i]->applier;
fin>>fp[i]->applicationdate>>fp[i]->applicationdate;
fin>>fp[i]->applyreason>>fp[i]->applyreason;
i++;
}
fin.close();
ofstream fout("data.txt",ios::out);
for(j=1;j<i-1;j++)
{
fout <<"申请人姓名 "<<fp[j]->applier<<"\n";
fout <<"申请日期 "<<fp[j]->applicationdate<<"\n";
fout <<"申请理由 "<<fp[j]->applyreason<<"\n";
}
fout << flush;
fout.close();
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询