questions
1-: why do i have to put cin.ignore(); ?
2- this is the function for opening files :
void Tran(tempt a[], int b)
{
string *file=new string[b];
ofstream *outfile=new ofstream [b];
cout<<"The names of the files are: "<<endl;
for (int i=0;i<b;i++)
{
file[i]="C:\\My resieved files\\"+a[i].name.first+"_"+a[i].name.last+".xls";
outfile[i].open(file[i].c_str());
while (!outfile[i])
{
cout<<"ERR"<<endl;
exit(1);
}
cout<<"File number "<<i+1<<" name is: "<<file[i]<<endl;
outfile[i]<<"first name\t"<<"last name\t"<<"ID\t"<<"telephone\t"<<"Address\t"<<"Gr1\t"<<"Gr2\t";
outfile[i]<<"Gr3\t"<<"Gr4\t"<<"Gr5\t"<<endl;
outfile[i] << a[i].name.first <<"\t";
outfile[i] << a[i].name.last <<"\t";
outfile[i] << a[i].id << "\t";
outfile[i] << a[i].tel << "\t";
outfile[i] << a[i].add<<"\t";
for(int j=0; j<5; j++)
outfile[i]<< a[i].grade[j]<<"\t";
outfile[i]<<endl;
outfile[i].close();
}
}
is it right?
3- why did you tell me that i have to do file.clear(); ?
i want to keep the files not to erease them?