Open a file by name

Hi,

I assigned the name of the file to string vector.

I mean when I print the vector, it seems like

cout<< files[0];

It prints file.txt

and I want to open the file by using vector.

I tried ifstream file ("files[0]"); and ifstream file (files[0]);

but they did not work. Please help me out !
The constructor and open function use c-strings (char*), so for it to work, you just have to do this:
ifstream file (files[0].c_str());
thank you it worked ;)
Topic archived. No new replies allowed.