#include<iostream>
#include<conio.h>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ofstream myfile[2];
string name[2];
int roll[2];
int marks[2];
int i;
for(i=0;i<=1;i++)
{ myfile[i].open("info"[i]".txt",ios::out);
cout<<"enter the name of "<<i+1<<" student :";
getline(cin,name[i]);
cout<<"\n\nenter the roll number of "<<i+1<<" student :";
cin>>roll[i];
cin.get();
cout<<"enter the marks of "<<i+1<<" student :";
cin>>marks[i];
cin.get();
myfile[i]<<name[i]<<roll[i]<<marks[i];
myfile[i].close(); }
getch();
return 0;
}
the bolded line is giving an error.i want to open two different files inside the loop.one solution is that i should open both the files outside the loop and then proceed.but this wont be convinient if the number of student is large.plz suggest me some alternate method.