Witam.
Jak za pomocą fstream wczytać wybrany plik o nazwie, która jest w zmiennej int, albo string?
0
1
Jeżeli jest w zmiennej typu string, to:
#include <fstream>
//...
fstream file(name.c_str(), ios::in | ios::out);
//a potem
file >> word;
Jeżeli natomiast nazwa jest ukryta w zmiennej typu int, to trzeba:
#include <sstream>
#include <fstream>
//...
stringstream ss;
ss << numberNameFile;
ss >> word;
fstream file(word.c_str(), ios::in | ios::out);
//i posługiwanie się biblioteką fstream