I need some help to get the below code modify to get the BOLD lines goes to 7 files. I came up with the below code but It did not work as expected. Note that last line comes with "CutHere" line but it does not matter.
My problem is that I expect it to generate 7 files (Desfile_1 - Desfile_7) but it only generate 4 files - 4 files with bold & italic marked lines.
I need to find a way to generate 3 more files with other BOLD lines.
It seems, it skips one set due to code line - "}while ((offset2 = line.find("CutHere", 0)) == string::npos);".
I am not sure how to read from the just one before (previous) line after creating 1st file in order to avoid skipping one set alternatively.
Any ideas to get the below code modified to generate 7 files???
Something like this would perhaps be the simplest:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// ...
for( int fn = 1 ; file_in ; ++fn ) // loop till eof
{
std::vector<std::string> lines ;
// add lines one by one till cut_here
while( std::getline( file_in, line ) && not_cut_here(line) )
lines.push_back(line) ;
if( !lines.empty() ) // if there is atleast one line
{
// open the next output file
std::ofstream out_file( fine_name( prefix_dest, fn ) ) ;
// and write out the lines
for( const std::string& s : lines ) out_file << line << '\n' ;
}
}