I want to write a program that will copy a few lines in a file in another file. for example copy line 5 to 100 from file a and write it to file b. thanks
this is my code.but my code copying all content of file a to file b.
#include <iostream>
#include <fstream>
using namespace std;
int main(){
char line[100];
ifstream is("a.txt");
ofstream os("b.txt");
if (is.is_open()){
while (!is.eof()){
is.getline(line,100,'\n');
os << line << endl;
}
}
else{
cout << "a.txt couldn't be opened. Creat and write something in a.txt, and try again." << endl;
}
return 0;
}