I'm using the boost::filesystem library to open a file with a specific path file_path:
fs::ifstream file(file_path);
string str;
vector<string> filenames;
while(getline(file, str)){
filenames.push_back(str);
}
This code has been adapted from regular C++ code without boost. I initially was reading in a file placed in my current directory but I had to edit the path. Now it appears that getline is not working correctly. Is there a boost alternative to getline so that I can parse the file line by line and read them into the vector?
Thanks!
The answer above is absolutely correct. In case anyone wants full code :
boost::filesystem::ifstream fileHandler(fileName);
string line;
while (getline(fileHandler, line)) {
cout << line << endl;
}