I really don't understand why if I use f.open(filename.c_str(),ios::in) works only if filename is a string defined as a string type, but not if filename is been converted from a stringstream type.
I need stringstream type, because I have to open different folders, so I use the program to create the wanted adresses.
Thankyou your cooperation.
using namespace std;
//c++ -o iso iso.cpp `root-config --cflags --glibs`
int main (int argc, char **argv)
{
int n_gruppo, n_righe;
cout << "write the number of the folder: " << endl;
cin >> n_gruppo;
int num_vol[6]={1,2,3,5,7,10};
for (int i = 0; i < 6; ++i)
{
//combining the string
stringstream ss;
ss <<"/home/student/isoterma"<<n_gruppo<<"/pressione_vol"<<num_vol[i]<<".txt"<<endl;
string filename = ss.str();//conversion sstream in string
cout << filename << endl;
double sumsq = 0, sum = 0, s;
//cicle of reading
ifstream f ;
f.open(filename.c_str(), ios::in);//ricorda di mettere '.c_str()' infondo se è una stringa
for (int io = 0; io < n_righe ; io++)
{
f >> s;
cout << "value N° " << io << " is" << s << endl;
sum += s;
sumsq += pow(s,2);
}
f.close();
}
return 0;
}