struct student{
char name[20];
char course[20];
int age;
float gpa;
};
using namespace std;
main()
{
ifstream infile;
infile.open("student data.txt");
ofstream outfile;
outfile.open("student data 2.txt");
if(!infile || !outfile)
{
cout << "error opening or creating file" << endl;
exit(1);
}
student stu[2];
infile.seekg(0, ios::beg);
while(!infile.eof())
{
int i;
for(i=0; i<=2; i++)
{
infile >> stu[i].name;
infile >> stu[i].course;
infile >> stu[i].age;
infile >> stu[i].gpa;
}
}
outfile.seekp(0, ios::beg);
int i =0;
while(i<3)
{
outfile << stu[i].name << endl;
outfile << stu[i].course << endl;
outfile << stu[i].age << endl;
outfile << stu[i].gpa << endl;
i++;
}
infile.close();
outfile.close();
}
I am trying to figure out why this code is not working... its not giving any compilation error but when i run the application it stops working.it says rough.exe (app name) is not working. can anyone help :(