#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream stream1("source.txt");
string line ;
ofstream stream2("target.txt");
while(std::getline(stream1, line))
{
stream2 << line << endl;
cout << line << endl;
}
stream1.close();
stream2.close(); return 0;
}
我想让这个程序每10行读一遍并写入我的文件。每隔X行读写一次文件
我该如何去做这件事?
广东话你使用一些柜台?仍然需要每次调用getline,但是只有在计数器命中10时才将其放入另一个文件的流中,然后重新初始化计数器 – Arunmu 2012-02-04 07:38:18