Please find the error.. it says that the output function and the fil function donot have prtotypes?

#include<fstream.h>
#include<string.h>
#include<conio.h>


int ctr=0;

class student
{

public:

int roll;
char name[10];

int mark1,mark2,mark3;
int percent;
char grade;

void fil(student a )
{
student d= a;
fstream f;
f.open("student.txt",ios::in|ios::app);
f.write((char*)&d,sizeof(d));
f.close();
};

void input()
{
cout<<"enter name : \n";
cin>>name;
cout<<"enter roll no. pls : \n";
cin>>roll;
cout<<"\nmarks of first subject : ";
cin>>mark1;
cout<<"\nmarks of second subject : ";
cin>>mark2;
cout<<"\nmarks of third subject : ";
cin>>mark3;
calc();
};


void calc()
{
int percent = (mark1+mark2+mark3)/3 ;
if(percent<50)
grade='E';
else if ((percent>=50)&&(percent<60))
grade = 'D';
else if ((percent>=60)&&(percent<75))
grade = 'C';
else if ((percent>=75)&&(percent<90))
grade = 'B';
else if ((percent>=90)&&(percent<100))
grade = 'A';

};


void display()
{
student d;
fstream f;
f.open("student.txt",ios::out);
f.read((char*)&d,sizeof(d));
while(f)
{
cout<<"\n your name is : "<<d.name;
cout<<"\n your roll no. is : "<<d.roll;

cout<<"\npercent : "<<d.percent;
cout<<"\ngrade: "<<d.grade;
f.read((char*)&d,sizeof(d));
}
f.close();

};


};



void main()
{
student s[20];

clrscr();
cout<<"\t\t\tWelcome\n";
int ans;
cout<<"\n1. Enter new record.\n2. View all records.\n3. exit";
cin>>ans;
for(int i=0;ans!=3;i++)

{
if(ans==1)
{
s[ctr].input();
fil(s[ctr]);
ctr++;
}

else
{
cout<<"Total No. of student entries made :"<<ctr;
display();
}

cout<<"\n1. Enter new record.\n2. View all records.\n3. exit";
cin>>ans;


}
cout<<"\n thank you";


getch();

}
move fil declaration from class to global namespace.
didnot work for either of them... and why dosent defining as

void student::display work?
It works for me.
Post full code after you changed it.
Problem is that fil is non-static class member function. It shoulbe called like:
1
2
student someStudent; //
someStudent.display();


What compiler do you use? Your code didn't work for me untill I included <iostream>, deleted .h from fstream and placed using namespace std; or just added std to everything.
Topic archived. No new replies allowed.