Scusa un ultima domanda:

come posso inserire degli interi nel nome del file al posto di fn.str() e gn.str() ?

se faccio:

stringstream fn;
stringstream gn;

n=0;
p=1;
fn.str("");
gn.str("");

fn << n;
gn << p;

file= "trans_nodi"+fn.str()+"run"+gn.str()+".txt";

mi dice:

lettura_dati.cpp:19: error: aggregate ‘std::stringstream fn’ has incomplete type and cannot be defined
lettura_dati.cpp:20: error: aggregate ‘std::stringstream gn’ has incomplete type and cannot be defined

dove sbaglio?