When I use the std::ifstream to open a file that has been written in dos format, the ifstream does not seem to be able to open the file correctly since when I call good() on the stream afterwards it fails (returns false). I tried opening the file in binary mode as well as the default “in” mode and neither worked. If I convert the file to unix using dos2unix, everything works fine.
The goal behind being able to do this is that I want to be able to read a file and parse it, but I cannot guarantee that the file has not been saved in dos (Windows) or unix (Linux) format. Ideally, I would like to be able to use the ifstream.
Any suggestions?
Thanks!
The file format will NOT affect your ability to open it.
It is more likely that your path is not correct.