#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(void)
{
ifstream in;
ofstream out;
out.open("tmp.txt");
in.open("hello.txt");
string buf;
int count = 0;
while (getline(in, buf)) {
count++;
if (count == 4)
in.seekg(0, ios::beg); //这里使用了seekg()来使文件指针重新定位到头部, 也可以写成in.seek(0);
out << buf << endl;
}
in.close();
out.close();
return 0;
}