Is there any way to open multiple files concurrently and for example read the first line of each and the do some task with them, then read the second line of all of them and do some task again with them, etc until all of them are finished?
It seems that when I reach the second loop all the fileStreams are closed :(
Code:
for (int i = 0; i < (int)products.size(); i++)
{
string fileName = folder + "\\" + products[i] + "_" + parameters_.getDate() + ".csv";
fileNames_.push_back(fileName);
ifstream fileStream(fileName.c_str());
fileStreams_.push_back(&fileStream);
eof_.push_back(false);
}
for (int i = 0; i < (int)fileStreams_.size(); i++)
{
if (fileStreams_[i]->is_open())
{
string dummy;
getline (*fileStreams_[i],dummy);
cout << i << ": " << dummy << endl;
}
}
Comment