第2个回答 2015-08-13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <fstream>
#include <string>
using namespace std;
int main()
{
vector<string> vecContent;
string strLine;
ifstream inFile("e:\\test.txt");
while (inFile)
{
getline(inFile, strLine);
vecContent.push_back(strLine);
}
inFile.close();
// 删除第一行
vecContent.erase(vecContent.begin());
ofstream outFile("e:\\test.txt");
vector<string>::const_iterator iter = vecContent.begin();
for (; vecContent.end() != iter; ++iter)
{
outFile.write((*iter).c_str(), (*iter).size());
outFile << '\n';
}
outFile.close();
return 0;
}