When is c_str() needed to open file?

I'm inputing data from a txt. file using inFile.open(filename.c_str());. Everything works fine, but I tried inputing the file without c_str(), just inFile.open(filename); and it worked fine as well. I initialized my filename as a string and was wondering why it worked without c_str(). Thx
You only need to convert it to a c-string if you are not using c++11 or later.
http://www.cplusplus.com/reference/fstream/ifstream/open/
Look at the prototypes based on the standard.
Topic archived. No new replies allowed.