reading several files in the loop

Hi,

I want to read several files in a loop
& use that in my code.
Can anyone help please. I am new in this field.
Also how to define different file names as array of strings
so as to loop over them.

Thanks in advance.

prince.
ifstream theFile1("file1.txt");
ifstream theFile2("file2.txt");

string str1, str2, string1, string2;

 if(!theFile1)
{
     cout << "Error opening file." << endl;
     return -1;
}

while (!theFile1.eof())
{
     getline(theFile1, str1);
     string1 += str1;
     string1 += "\n";
}


Just put that in a loop?
Topic archived. No new replies allowed.