I am fairly new to C++. I have been trying to access the names of files in a specific folder. I'm not sure if I should use a vector or a list. I tried a list, just because that's what I'm used to.
#include <iostream>
#include <string>
#include <fstream>
#include <list>
using namespace std;
list<string> file_list(string file)
{
list<string> list;
ifstream files;
string line;
files.open(file);
while (getline(files, line)) {
list.push_back(line);
}
files.close();
cout << &list << endl;
return list;
}
When I debug the variable line
stays blank and it prints off 0x7fff5fbff6b0
.
I am trying access my downloads folder. The string variable 'file' is a direct path to it. It opens just fine, but I can't access the file names inside it.