把txt中的东西读取到一个数据结构中,把第二条删了,然后输出到txt
追问就是不会啊
追答#include<iostream>
#include<fstream>
#include<string>
#include<list>
using namespace std;
struct A
{
string id;
string sex;
int age;
string local;
string project;
};
int main()
{
list<A> T;
ifstream fin;
fin.open("1.txt");
A temp;
while (fin >> temp.id >> temp.sex >> temp.age >> temp.local >> temp.project)
{
T.push_back(temp);
}
auto ite = T.begin();
T.erase(ite++);
fin.close();
ofstream fout;
fout.open("1.txt");
ite = T.begin();
auto eite = T.end();
while (ite != eite)
{
cout << ite->id << ends << ite->sex << ends << ite->age << ends << ite->local << ends << ite->project;
}
fout.close();
system("pause");
return 0;
}