#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