Hello Peers,
I have a sequence of data files (Site_1.txt, Site_2.txt,.....,Site_N.txt) that i need to read into my main program. Although I managed to construct the file names (as character arrays using sprintf), I am not sure of how to pass them to the ifstream, as it needs the file names to be of string type.
Thanks
int Ns,Fj;
char buffer[50],S[]="Site_";
for (Ns=1;Ns<=N_Tables;Ns++)
{
Fj=sprintf(buffer,"%s",S);
Fj+=sprintf(buffer+Fj,"%d.txt",Ns);
//cout<<buffer;
ifstream ifData(buffer);
if(!ifData){cout<<"Cannot open the Data file"; return 1;}
}