How to read files inside a folder using the value from another input file

Hi. I am currently doing my assignment and it requires me to open a folder, read a file, and then open a file in the folder with the same name as the one in the read file. Meaning, there is folderA which has several numbers of folders, such as folder1, folder2, folder3, .... and a text file called folders.txt. folders.txt contains the names of folders inside folderA. So folders.txt looks like this.
folder1
folder2
folder3
....

And inside those folders (folder1, ...), there are also a few files in the CSV format, such as day1.csv, day2.csv, day3.csv, ...., and a text file called days.txt, containing the names of the CSV files. days.txt file looks like this.
day1.csv
day2.csv
day3.csv
....

So, what I'm supposed to do is, read the folders.txt inside folderA line by line. And then, after reading each line, I need to read the days.txt file in the folder with the name on that line. Then, I read days.txt line by line and read the CSV file with the same name.
It must be something like this, if folders.txt and days.txt look like as shown above.
Read the first line of folders.txt, which is "folder1".
Read the first line of days.txt in folder1, which is "day1.csv".
Read the day1.csv file and use the values.

Currently my program is something like this.
I can read the folders.txt but I cannot read days.txt.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int main() 
{
ifstream folderFile ("folderA/folders.txt");
string fold, days, value;

while (getline(folderFile, fold))
{
ifstream folder ("fold/days.txt");
while (getline(folder, days))
{
ifstream dayFile (days);
while (getline(dayFile, value))
{
cout << value << endl;
}
}
}
}
Topic archived. No new replies allowed.