#include <iostream>
using std::cin; using std::cout; using std::endl; using std::cerr;
using std::istream; using std::ostream;
#include <fstream>
using std::ifstream;
using std::ofstream;
#include <string>
using std::string;
#include <vector>
using std::vector;
#include <iterator>
using std::istream_iterator; using std::ostream_iterator;
void write_oe(ifstream &in, ofstream &oo, ofstream &oe){
if (in.is_open()){
for (istream_iterator<int> in_iter(in), eof; in_iter != eof && oo.is_open() && oe.is_open();
++in_iter){
if (*in_iter % 2 != 0){
ostream_iterator<int> out_o(oo, " ");
out_o = *in_iter;
cout << "Write " << *in_iter << " to file1" << endl;
} else {
ostream_iterator<int> out_e(oe, "\n");
out_e = *in_iter;
cout << "Write " << *in_iter << " to file2" << endl;
}
}
} else {
cout << "Failed to open file" << endl;
return;
}
}
int main() {
string input_path("/home/raymain/CLionProjects/CPPLv1/test.txt");
ifstream input(input_path);
string output_odd("/home/raymain/CLionProjects/CPPLv1/output1_odd");
ofstream output1(output_odd);
string output_even("/home/raymain/CLionProjects/CPPLv1/output2_even");
ofstream output2(output_even);
write_oe(input, output1, output2);
}