hey all



please help e in this problem .. i didnt find any reply ..

is it wrong to make a pointer to array of objects of a struct or what is wrong in the code?
this is the whole cod of the program
Code:

#include<iostream>
#include<cstdlib>
#include<fstream>
#include<iomanip>
using namespace std;
void sort_fn(student k,int size);
void show_fn(student k ,int size);

struct student
{
	char name[10];   // for the name of the student
    int BN;// for the bench number
	int year ,section,exam;
  double mark;
}; //for the mark of the student


int main()
{
	student m;
	int range[6]={0,0,0,0,0,0};
	double sum ,av; // sum is the sum of the marks of students and av is their average
	int i=0;  //counting the nuber of students
	
	sum =0;
    ifstream fin;
    ofstream fout;
    fin.open("E://mark.txt");
    if (fin.fail())
	{
       cout<<"Can not open file\n";
        exit(1);
	}
  fout.open("E://results.txt");
  fin>>m.name;
  while(!fin.eof())
  {
	  fout<<m.name;
	  fout<<"  ";     //space
	  fin>>m.BN;
	  fout<<m.BN;
	  fout<<"  ";
	  fin>>m.year;
	  fout<<m.year;
	  fout<<"  ";
	  fin>>m.section;
	  fout<<m.section;
	  fout<<"\t";
	  fin>>m.exam;
	  fout<<m.exam;
	  fout<<"\t";
	  fin>>m.mark;
	  if ((m.mark>=0)&&(m.mark<5))
		  range[0]++;
	  else if((m.mark>=5)&&(m.mark<10))
		  range[1]++;
	  else if((m.mark>=10)&&(m.mark<15))
		  range[2]++;
	  else if((m.mark>=15)&&(m.mark<20))
		  range[3]++;
	  else if ((m.mark>20)&&(m.mark<25))
		  range[4]++;
	  else
		  range[5]++;

	  sum+=m.mark;
	  fout<<m.mark;
	  fout<<endl;
	  i++;
	  fin>>m.name;
  }
  av=sum/i;
  fout<<" the average of the students is :"<<av <<endl;
  fout<<" the number of students having score between 0 and less than 5 :"<<range[0]<<endl;
  fout<<" the number of students having score between 5 and less than 10 :"<<range[1]<<endl;
  fout<<" the number of students having score between 10 and less than 15 :"<<range[2]<<endl;
  fout<<" the number of students having score between 15 and less than 20 :"<<range[3]<<endl;
  fout<<" the number of students having score between 20 and less than 25 :"<<range[4]<<endl;
  fout<<" the number of students having score between 20 and 30       :"<<range[5]<<endl;
  student *p =new student[i];
  int j=0;
  fin>>p[j].name;
  while(!fin.eof())
  {
	 
	  fin>>p[j].BN;
	  
	
	  fin>>p[j].year;
	  
	  fin>>p[j].section;
	 
	  fin>>p[j].exam;
	 
	  fin>>p[j].mark;
	 
	   
	 j++;
	  fin>>p[j].name;
  }
  sort_fn(p,i);
  show_fn(p,i);

  fin.close();
  fout.close();
  delete []p;
  return 0;
  

}

void sort_fn(student & k,int size)
{
	student temp;
	for (int i=0 ;i<size-1 ;i++)
	{
		for (int j=i+1;j<size ;j++)
		{
			if (k[i].mark<k[j].mark)
			{
				temp=k[i];
				k[i]=k[j];
				k[j]=temp;
			}
		}
	}
}

void show_fn(student & k ,int size)
{
	for (int i=0;i<size;i++)
		cout<<k[i].name<<setw(10)<<k[i].section<<setw(15)<<k[i].mark<<endl;
}

thanks in advance