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!
boost::filesystem::ifstream
is just another input stream, and all standard algorithms apply to it the same way they apply to std::ifstream
. std::getline
works with it as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With